English 中文(简体)
按属性分列的 jquery td 内容 - 不能使用儿童或找到方法? [关闭]
原标题:jquery td content by attribute - cannot use children or find methods? [closed]

我不知道什么应该是一个简单的任务:

http://jsfidle.net/elen/7agUc/3/

$(document).on("change", td[col=cat_id] select ,function() {
    var v = $(this).val();
    var tr = $(this).parent().parent(); // getting parent row

    var tr_id = tr.attr( primary_key );
    var d = tr.childern( td[col=Artist ).html(); // getting text in the specific cell of the same row

    alert(d);

});​

上述代码投出错误 - “ 子女方法不支持 ”

下列作品:

var d = $("tr[primary_key="+tr_id +"] td[col=Artist]").text();

但为何我不能只使用 childs () find () : :

var d = tr.find( td[col=Artist ).text();

还是我漏掉了什么?

最佳回答

您有一个打字符: 将 chiltern 替换为 children

问题回答

固定下行:

var d = tr.childern( td[col=Artist ).html();

收件人:

var d = tr.children( td[col=Artist] ).html();

"http://jsfiddle.net/7agUc/6" rel="无跟踪" >Work

在选择器里你少了一个, 加上你拼错孩子的拼法。 尝试使用 :

 tr.children( td[col=Artist] ).html()

尝试此 - & gt;

$(document).on("change", td[col=cat_id] select ,function() {
    var v = $(this).find( option:selected ).val();
    var tr = $(this).parent().parent();

    var tr_id = tr.attr( primary_key );
    var d = tr.find( td[col=Artist] ).html();

    alert(d);

});​




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签