kaira
kaira

Reputation: 117

find closest value in jquery

i have 2 web page home.aspx and about.aspx , here i m trying to load about.aspx page table in popup box,

about.aspx page

<table>
  <tr>
    <td class="Uname">Chat Is Name</td>
  </tr>    
  <tr>
    <td id="UserMessage">abc</td>
  </tr>           
  <tr>
    <td>
      <input type="button" id="bt_Send" 
             title="Click here to Send" value="Send" />
    </td>
  </tr>
</table>
<div id="mbox"></div>    

Code:

$('#mbox').load('about.aspx #msg');   
$("#bt_Send").live('click', function () {               
  var a = $(this).siblings('.Uname').attr('text');
  alert(a);        
});

here i'm not getting value of that control

Upvotes: 2

Views: 293

Answers (2)

Sampson
Sampson

Reputation: 268414

We are encouraged to no longer use $.live. Instead, you should be using the $.on method:

$("#mbox")
  .load("about.aspx #msg")
  .bind("click", "#bt_Send", function(){
    var a = $(this).closest("table").find(".Uname").text();
  });

Upvotes: 0

gdoron
gdoron

Reputation: 150273

You can accomplish this by:

var a = $(this).closest('table').find('.Uname').text();

Upvotes: 6

Related Questions