I have an HTML Div (I use Twitter Bootstrap for hide-show div2 ) that looks like this:
HTML:
<div id="div1"> <button id="mybtn">Button</button> <div id="div2" class="modal hide fade span12" style="display: none;"> <button id="anotherButton" data-char="">AnotherButton</button> </div> </div>
With jQuery im trying to change the value of data-char while im is clicking on mybtn . But without success, the reason div2 is hidden. console.log($('#anotherButton')); returns an empty array.
Is there a way to access a hidden DOM with jQuery or Javascript?
* Edit: * Having tried that this does not work better, return undefined :
$('#mybtn').live('click', function(e) { //or e.preventDefault(); $('#anotherbutton').attr("data-char", "assigned"); alert($('#anotherbutton').attr("data-char")); });
source share