【发布时间】:2013-04-05 12:35:30
【问题描述】:
在点击的ID里面选择p标签有问题,代码如下;
<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 编辑器中编写一些代码。
【问题讨论】:
-
离题:tr 元素应该只有 td 子元素。另外 $(this 'p') 甚至在语法上都不正确
-
如果你把 HTML 放到一个页面中,
p将在构建 DOM 时移动到其他地方(因为它不是tr的有效子代):demonstration JS Fiddle。
标签: jquery html jquery-ui jquery-selectors