点击div可更改其他div的内容 [英] Clicking a div changes another div's content

查看:467
本文介绍了点击div可更改其他div的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要更改< div class =tcw-content> 中的内容,当我点击另一个div,但是我从来没有使用过Ajax (也许它不必在Ajax,但我不能想到一个JS / CSS的方式,例子赞赏:)),任何人有任何例子为我请吗?例如,用户将点击< li id =tab-tab_700964class =grp>< a>组A< / a>< / li>

I'd like the content inside <div class="tcw-content"> to change, when another div is clicked, however I have never used Ajax (maybe it doesn't have to be done in Ajax, but I can't think of a JS/CSS way, examples appreciated :) ), would anyone have any examples for me please? For example, the user will click onto <li id="tab-tab_700964" class="grp"><a>Group A</a></li> and as soon as the hotspot is clicked, the content inside the above mentioned div will change.

如何实现这一目标?

推荐答案

您可以使用 jQuery ,例如:

You can use jQuery, example:

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
    $('#tab-tab_700964 a').on('click', function(){
      $('.tcw-content').html('hey');
    }); 
});
</script>

<li id="tab-tab_700964" class="grp"><a>Group A</a></li>
<div class="tcw-content">
    hello
</div>

这篇关于点击div可更改其他div的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆