admin管理员组文章数量:1023538
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?
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?
5 Answers
Reset to default 1You 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.
$('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();
});
see DEMO by all THREE WAYS
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.
Example fiddle
$('#ResumeWrite input[type="button"]').click(function(){
alert($(this).parent().prev().find('span').text())
})
Demo: Fiddle
alert($(".font18").text());
or alert($("#resumeWrite .highlight span").text()); You should read the jquery doc, and follow some tutorial, it's very basic...
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?
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?
5 Answers
Reset to default 1You 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.
$('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();
});
see DEMO by all THREE WAYS
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.
Example fiddle
$('#ResumeWrite input[type="button"]').click(function(){
alert($(this).parent().prev().find('span').text())
})
Demo: Fiddle
alert($(".font18").text());
or alert($("#resumeWrite .highlight span").text()); You should read the jquery doc, and follow some tutorial, it's very basic...
本文标签: javascripthow to get lttdgt value with span class in jqueryStack Overflow
版权声明:本文标题:javascript - how to get <td> value with span class in jquery - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745520367a2154288.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论