[英]make more entire div clickable on wordpress using jQuery
总结问题
我 state 我对 html 和 javascript 语言几乎一无所知,我知道 ZC7A628CBA22E2A28EB17B5F5C66 在 wordpress 上,使用可视化作曲家,我试图使整行可点击。 我已经使用在线创建的 jQuery 代码完成了它:
<script type="text/javascript">
jQuery(".LinkZoom1").click(function() {
window.location = "http://www.framedvision.org/portfolio/videomapping_oggetti_milano/";
});
</script>
我已将 java 的 object 添加到可视化作曲家中,并输入了代码。 创建类后,插入链接,将“光标:指针”function 添加到 CSS,一切正常。
问题是它只能在单行上工作。 当我尝试复制代码、分配不同的类和链接以创建更多可点击的 div 时,它不起作用。 结果是只有页面的第一个 div 是可点击的,div 不是。
我试过的
我以不同的组合尝试了以下代码:
<script type="text/javascript">
jQuery(".class1”).click(function() {
window.location = “#1”;
});
</script>
<script type="text/javascript">
jQuery(".class2”).click(function() {
window.location = “#2”;
});
</script>
<script type="text/javascript">
jQuery(".class3”).click(function() {
window.location = “#3”;
});
</script>
<script type="text/javascript">
jQuery(".class4”).click(function() {
window.location = “#4”;
});
</script>
<script type="text/javascript">
jQuery(".class5”).click(function() {
window.location = “#5”;
});
</script>
始终将 object 用于 java 代码:我将它们放在一起,分别放在我想要使其可点击的行中,它不起作用。 结果总是一样的:只有第一个 div 变得可点击。 即使将 java 代码的 object 从第一行移到其他行,结果也是一样的。 第一个 div 始终是唯一可点击的。
为了确保你的js jquery 代码有效,通过a.js 文件添加脚本
但首先,查找主题的 footer.php 文件并添加以下代码:
jQuery(document).ready(function(){
jQuery(".your_class").click(function() {
window.location = "https://bluebezer.com.br";
});
});
在 wp_footer () 之后;
<?php wp_footer(); ?>
<!-- add here the sample code -->
jQuery(document).ready(function(){
jQuery(".your_class").click(function() {
window.location = "https://bluebezer.com.br";
});
});
</body>
</html>
请记住,您必须将 class 放入您希望它可点击的元素中,并且元素必须具有您在 javascript 代码中使用的 class 与您编写的完全相同。
<div class="your_class"> <!-- this will execute the clickable code -->
<!-- ... other code -->
</div>
<div class="your_class35413"> <!-- this will not execute the clickable code -->
<!-- ... other code -->
</div>
<div class="your_class"> <!-- this will execute the clickable code -->
<!-- ... other code -->
</div>
<div class="your_class4156130"> <!-- this will not execute the clickable code -->
<!-- ... other code -->
</div>
<div class="your_class"> <!-- this will execute the clickable code -->
<!-- ... other code -->
</div>
我找到了解决方案。 通过导入上面编写的代码,如您所纠正,它可以工作。 我不知道这种方法在理论上是否正确,但它工作正常。 所以...
在可视化作曲家中,您必须插入 object 以在要使其可点击的每一行中添加 java 代码(例如:对于 5 个可点击的 div,您制作 5 个对象以插入 Z93F725A07423D1C8836F 代码) 在每个 object 中,您必须为每个 class 插入特定代码:
<script type="text/javascript">
jQuery(".class1”).click(function() {
window.location = “#1”;
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.