Reputation: 1468
My table is
<table id="ResumeWrite" class="Vasprice" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<th width="20%" class="bdrL_blue valignT highlight">
<span class="font18">0 to 1 year Experience</span>
</th>
<th>
<input type="button" value="submit"/>
</th>
</tr>
i want to alert the value 0 to 1 year Experience
when i click the button. how to do in jquery?
Upvotes: 2
Views: 6408
Reputation: 1391
You can do this by many ways. I think most simple is:
$(".font18").text();
$(".font18").html();
or
$("#ResumeWrite span.font18").text();
Last string only improves the accuracy of the finding desired item.
Upvotes: 1
Reputation: 10388
$('input[type="button"]')click(function(e){
e.preventDefault();
alert($(".bdrL_blue").text());
});
and you can do by also following way
$('input[type="button"]').click(function(e){
e.preventDefault();
$(this).closest('tr').find('span').text();
//or
$(this).closest('tr').find('th').text();
});
Upvotes: 1
Reputation: 563
alert($(".font18").text());
or alert($("#resumeWrite .highlight span").text()); You should read the jquery doc, and follow some tutorial, it's very basic...
Upvotes: 0
Reputation: 388416
$('#ResumeWrite input[type="button"]').click(function(){
alert($(this).parent().prev().find('span').text())
})
Demo: Fiddle
Upvotes: 0
Reputation: 337646
Try this:
$('input[type="button"]').click(function() {
var text = $(this).closest('tr').find('span').text();
alert(text);
});
Note, I didn't use the classes on the element to select it as they appear to be style classes, and not semantically linked to the content of the element.
Upvotes: 0