【发布时间】:2016-04-29 09:59:58
【问题描述】:
如何使用jquery 函数.click() 使输入type="button" 起作用
Internet Explorer 和 Safari?它在 Mozilla、Chrome 和 Opera 中运行良好。
例如,点击wenn按钮隐藏的div显示:
<input type="button" value="Comments(<?php echo $commentCounter?>)" data-id="<?php echo $productArray[$key]["ID"].$_SESSION["userSession"];?>" class="CommentsSection"/>
<div id="<?php echo $productArray[$key]["ID"].$_SESSION["userSession"];?>" style="display:none">
<?php
echo"This is hidden div";
?>
</div>
JavaScript:
<script type="text/javascript">
$(document).ready(function(){
$(".CommentsSection").click(function(){
var sectionID=$(this).attr('data-id');
$("#"+sectionID).show();
});
});
</script>
【问题讨论】:
-
你能粘贴生成的 HTML 而不是 php 代码吗?
标签: javascript jquery html safari explorer