html - jQuery: How can I assign a variable back to a hidden element in the document? -
how can assign variable (button id clicked), jquery diaglog, hidden element (myhiddenid) in document later use?
<table border="0" class="time_data"> <td><button type="button" id='001' class="del-fruit" > apple </td> <td><button type="button" id='002' class="del-fruit" > banana </td> <td><button type="button" id='003' class="del-fruit" > cantalope </td> </table> <div id='myhiddenid' style="display:none;"></div> <script type="text/javascript"> $("#dialog-form").dialog({ autoopen: false, height: 150, width: 350, modal: true, resizable: false, buttons: { 'yes': function() { var bvalid = true; allfields.removeclass('ui-state-error'); bvalid = bvalid if (bvalid) { //the assining of myhiddenid should here!! //and should contain id of button clicked. $(this).dialog('close'); } }, no: function() { $(this).dialog('close'); } }, close: function() { allfields.val('').removeclass('ui-state-error'); } }); $('.del-fruit') .button() .click(function() { $('#dialog-form') .dialog( "option", "title", this.id ) .dialog('open'); }); </script>
agreed first answer, if want use hidden div:
set:
$("div#myhiddenid").html("whateverid"); get:
var foo = $("div#myhiddenid").html();
Comments
Post a Comment