Actually there is such a button:

<input type="button" value="-" onclick="changeSign(this.value)" name="r_abs_sph_sign" id="r_abs_sph_sign_min"/> 

When you click, its value attribute with a minus should change to a plus. That's actually the question - how to use jQuery in the changeSign () function to select this button and change its value?

PS: There will be about eight such buttons on the page, so I would like to do all this with one function and not to write my own for each button.

    1 answer 1

    8 of the same type and all id ?
    Think about architecture more, this is a bad approach, it is better to use classes.

     $(function(){ $('.r_abs_sph_sign_min').click(function(){ // ΠŸΠ΅Ρ€Π΅Π±ΠΈΡ€Π°Π΅ΠΌ всС ΠΊΠ½ΠΎΠΏΠΊΠΈ с классом r_abs_sph_sign_min ΠΈ ΡΠ»ΡƒΡˆΠ°Π΅ΠΌ событиС ΠΊΠ»ΠΈΠΊΠ° // this ΡƒΠΊΠ°Π·Ρ‹Π²Π°Π΅Ρ‚ Π½Π° ΠΊΠ½ΠΎΠΏΠΊΡƒ this.value = this.value === '-' ? '+' : '-'; // МСняСм Π·Π½Π°ΠΊ Π² зависимости ΠΎΡ‚ Ρ‚ΠΎΠ³ΠΎ, ΠΊΠ°ΠΊΠΎΠΉ сСйчас }); }); 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="button" value="-" name="r_abs_sph_sign" class="r_abs_sph_sign_min"/> | <input type="button" value="-" name="r_abs_sph_sign" class="r_abs_sph_sign_min"/> | <input type="button" value="-" name="r_abs_sph_sign" class="r_abs_sph_sign_min"/> | <input type="button" value="-" name="r_abs_sph_sign" class="r_abs_sph_sign_min"/> | <input type="button" value="-" name="r_abs_sph_sign" class="r_abs_sph_sign_min"/> | <input type="button" value="-" name="r_abs_sph_sign" class="r_abs_sph_sign_min"/>