Jquery 从td在集装箱舱内装载舱,一次一个?
我检查了类似的问题,但找不到答案 我有这个HTML:Jquery 从td在集装箱舱内装载舱,一次一个?,jquery,Jquery,我检查了类似的问题,但找不到答案 我有这个HTML: <table> <td> <a href="#">click me</a> <div class="showme"><p>test</p></div> </td> <td> <a href="#">click me</a> <div class="showme"><p>test
<table>
<td>
<a href="#">click me</a>
<div class="showme"><p>test</p></div>
</td>
<td>
<a href="#">click me</a>
<div class="showme"><p>test 2</p></div>
</td>
<td>
<a href="#">click me</a>
<div class="showme"><p>test 3</p></div>
</td>
</table>
<div class="container" rel="showme"></div>
将css设置为最初隐藏“showme”
.showme { display:none}
把你的希普换成这个
jQuery(document).ready(function($) {
$("td a").click(function() {
$(this).next().load($(this).attr('href'));
});
});
请记住,您无法使用javascript打开外部链接,如果您正试图这样做,那么您可能希望使用iframe而不是div在html中添加一个div
<table>
<td>
<a href="#">click me</a>
<div class="showme">
<p>
test</p>
</div>
</td>
<td>
<a href="#">click me</a>
<div class="showme">
<p>
test 2</p>
</div>
</td>
<td>
<a href="#">click me</a>
<div class="showme">
<p>
test 3</p>
</div>
</td>
</table>
<div class="container"></div>
试验
测试2
测试3
像这样的剧本
<style>
.showme { display:none}
</style>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$("td").click(function () {
var tow = $(this);
tow.find('div[class="showme"]').css('display', 'block');
$('.container').html(tow.find('div[class="showme"]'));
});
});
</script>
.showme{display:none}
jQuery(文档).ready(函数($){
$(“td”)。单击(函数(){
var tow=$(本);
tow.find('div[class=“showme”]')).css('display','block');
$('.container').html(tow.find('div[class=“showme”]);
});
});
也许这会满足您的需求
$(function(){
$("table td>a").click(function(e){
e.preventDefault();
//get the html content
var cont = $(this).parent().children(".showme").html();
//add it to the desired div
$(".container").html(cont);
});
});
你需要一点css
.showme{
display: none;
}等等,我误解了你的问题。我将在第二年编辑文章,它应该加载在容器分区中
.showme{
display: none;