-2

クリックした ID 内の ap タグの選択に問題があります。コードは次のとおりです。

<tbody>
    <tr id="test1">
    <p>
        Some random text that should show up in the dialog.
    </p>
        <td>test</td>
        <td>test</td>
    </tr>
    ... the rest of the tr's are identical, nothing else to see here.
 </tbody>


$('#test1, #test2, #test3, #test4').click(function(){
    $(this 'p').dialog();
});

ライブでテストします。http://team-blandsaft.no-ip.org/

stackoverflow エディターでコードを書くことに慣れたほうがよいでしょう。

4

2 に答える 2

5

.find()を使用

$(this).find('p').dialog();

または、コンテキストセレクターを使用できます

$('p',this).dialog(); 

これは内部的に find メソッドを使用します

他の人が述べたように、あなたは無効なhtmlを<p>の子として持っています<tr>

tr のMDN ドキュメントから

許可されているコンテンツ: 0 個以上<td><th>要素、またはそれらの混合

于 2013-04-12T20:48:22.897 に答える
0
$('#test1, #test2, #test3, #test4').click(function(){
    $(this).children('p').dialog();
});
于 2013-04-12T22:52:15.577 に答える