我有几个 ID 具有相同的类规范,但文本内容会发生变化。使用 jQuery,我想.job
在 click 函数上调用我的类以显示适当的#paper_appropriatejob
.
<script src="src/js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(".job").click(function(){
var theclass:String = this;
var thejob:String = theclass.substring(1);
$("#paper_"+thejob).fadeIn(400);
});
</script>
我第一次尝试了下一个qith,但没有结果:
<script type="text/javascript">
$(".job").click(function(){
$("#paper_"+ this).fadeIn(400);
});
</script>
的HTML:
<div id="inge_sys" class="job" style= "background-image: url('src/img/salles/explo/ingesys.png')"></div>
<div id="cosmo" class="job" style= "background-image: url('src/img/salles/explo/cosmo.png')"></div>
<div id="astro" class="job" style= "background-image: url('src/img/salles/explo/astro.png')"></div>
<div id="paper_cosmo" class="paper">Text</div>
<div id="paper_astro" class="paper">Text</div>