1

i have button set up like:

<button id="invOn2" style="float: left;">Item 2</button>

the button is inside a dialog, and i am trying to change the title of the button as the dialog is being opened:

$('#invOn2').button( "option", "label", "shwaf");

this isnt working, what is wrong?


the suggestions havent worked as of yet, im going to elaborate on the structure of what im doing:

//jquery setup

 $(function() {
      $('#invOnBox').dialog({
            autoOpen: false,
            resizable: false,
            height: 350,
            width: 300,
      });
      $('#invOnButton').click(function() {
            $('#invOn1 button').html('shwaf');
            $('#invOnBox').dialog('open');
            return false;
      });
    });

//the invDialog and inner button

 <div id="invOnBox" title="Inventory">
    <button id="invOn1" style="float: left;">Item 1</button>
    </div>

//the invOnButton

<button id="invOnButton" style="float: left;">Inventory</button>

thanks!

meres
  • 13
  • 1
  • 4
  • http://stackoverflow.com/questions/987967/how-to-change-an-elements-title-attribute-using-jquery – FosterZ Sep 08 '10 at 05:34

2 Answers2

2

try this:

$('#invOn2 button').html('shwaf');

Moin Zaman
  • 25,281
  • 6
  • 70
  • 74
1

Well 2 things:

This selector won't find any elements

$('#invOn1 button')

Since it tires to find a button element inside the element with id #inv0n1, so change it to only the ID selector.

$('#invOn1')

I would also do the changes on the dialog open event. This due to that my dialogs are often dynamic ones.

$('#invOnBox').dialog({
        autoOpen: false,
        resizable: false,
        height: 350,
        width: 300,
        open : function () {
            $('#invOn1').html('shwaf');
        }
  });

..fredrik

fredrik
  • 17,537
  • 9
  • 51
  • 71