Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging button text with JavaScript doesn't work in Opera (11.11) for <input type="submit" /> elements. Why?
    primarykey
    data
    text
    <p>Why is that changing a button text doesn't work in Opera 11.11 for elements like</p> <pre><code>&lt;input type="submit" value="Asdasd" id="blahblah_button" /&gt; </code></pre> <p>? (Didn't try it in earlier versions yet.)</p> <p>I tried it with jQuery and with "pure" JavaScript too, none of them worked. <br>This is the jQuery code I tried:</p> <pre><code>$('#blahblah_button').val('Blah-blah'); </code></pre> <p>and this is the "pure" JS-code:</p> <pre><code>document.getElementById('blahblah_button').value = 'Blah-blah'; </code></pre> <p>Why is that <b>none of them worked in Opera 11.11</b>?<br /><b>It DOES work in IE, Chrome and FF</b>, it surprises me that it doesn't work in Opera.</p> <p>I have to mention that it DOES work for button tags like this in Opera too:</p> <pre><code>&lt;button id="test_button" onclick="$(this).text('Blahblah');"&gt;Some text&lt;/button&gt; </code></pre> <p>Thanks for your answers in advance!</p> <hr> <h3>EDIT I. (0:40)</h3> <p>I forgot to mention that querying the button's value after the modification gives the result that it seems to work fine, which means it changes the structure in JS DOM, but doesn't rerender the visible button appropriately.</p> <p>This is the example code with which you can try this behaviour:</p> <p><a href="http://jsbin.com/inuxix/1/edit" rel="nofollow">http://jsbin.com/inuxix/1/edit</a></p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="hu" xml:lang="hu"&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Changing button text&lt;/title&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Button tag - WORKING &lt;button onclick="$(this).text('Blahblah_1');" id="test_button"&gt;Button_text (button_tag)&lt;/button&gt; &lt;/p&gt; &lt;p&gt;Input tag (type: submit) - NOT working &lt;input onclick="$(this).val('Blahblah_2');" type="submit" value="Submit_text" id="blahblah_submit_type" /&gt; &lt;/p&gt; &lt;p&gt;Input tag (type: button) - WORKING &lt;input onclick="$(this).val('Blahblah_3');" type="button" value="Button_text" id="blahblah_button_type" /&gt; &lt;/p&gt; &lt;p&gt; &lt;button onclick="alert($('#blahblah_submit_type').val());" id="val_button"&gt;Getting blahblah_submit_type's value&lt;/button&gt; &lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <hr> <h3>EDIT II. (4:41)</h3> <p>But I also have to mention that <b>it DOES work for input elements with "button" type</b> - so I complemented my code above with an element like this. I also marked which types do and which don't work.</p> <hr> <h3>EDIT III.</h3> <p>In the meantime, I tested it, and it doesn't work in Opera &lt;= <a href="http://opera-usb.com/download/operausb1111int.zip" rel="nofollow" title="Opera 11.11">11.11</a>, <strong>but this bug has been fixed in <a href="http://opera-usb.com/download/operausb1150int.zip" rel="nofollow" title="Opera 11.50">Opera 11.50</a></strong> though.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload