简体   繁体   English

点击的javascript不起作用

[英]javascript on click does not work

<script type="text/javascript">
    $(document).ready(function () {
        $("#HyperLink12").click(function () {
            $('#webpage_datalist_product_full').animate({ left: "+=285" }, 400);
        });
    });
</script>

                            <asp:HyperLink ID="HyperLink12" runat="server" 
                                ImageUrl="slide_arrow_right_click.png">HyperLink</asp:HyperLink>

                        </div>

on click the javascript does nothing ,i added my html code 在单击javascript时不执行任何操作,我添加了html代码

If all you're trying to achieve when clicking the hyperlink is the animation you show above, I recommend preventing the default action usually executed by clicking hyperlinks, which is navigating to the URL value stored in its href attribute. 如果单击超级链接时要实现的所有动作都是上面显示的动画,则建议您阻止通常通过单击超级链接执行的默认操作,该操作导航到存储在其href属性中的URL值。 So, for a start, change your code to this: 因此,首先,将代码更改为:

<script type="text/javascript">
    $(document).ready(function () {
        $("#HyperLink12").click(function (event) {
            event.preventDefault(); //Prevents the default hyperlink click action
            $('#webpage_datalist_product_full').animate({ left: "+=285" }, 400);
        });
    });
</script>

If this doesn't work and you need more help, feel free to comment; 如果这不起作用,并且您需要更多帮助,请随时发表评论; I will update my answer. 我将更新我的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM