gpt4 book ai didi

asp.net - jQuery 和 asp.net 不能很好地协同工作

转载 作者:行者123 更新时间:2023-12-01 03:56:35 25 4
gpt4 key购买 nike

请引用此页面:http://loadedgranola.valitics.com/_product_83484/blackberry_lime

我有一个 jQuery 脚本,它运行时用背景图像替换 h1 标签。当文档加载时它工作得很好,但是当我单击“添加到购物车”时,在 javascript 警报之后 jQuery 样式中断。由于 CMS 限制,我无法直接访问他们的 javascript 或任何 ASP 文件,但我认为必须有一个简单的解决方案。

我正在使用的代码:

jQuery(文档).ready(function(){

            var textReplacer = document.title.replace(/ /g,'');
jQuery("h1").addClass('replaced').css("background","url(../images/h1/" + textReplacer + ".png) no-repeat 0 0");
});

我也尝试过使用函数 pageLoad(sender, args) { magic 但没有运气。

最佳答案

给你..

jQuery(document).ready( function() {
jQuery('<style type="text/css" media="screen">h1{text-indent:-9999px!important;background:url(../images/h1/'+document.title.replace(/ /g,'') +'.png) no-repeat 0 0!important;}</style>').appendTo('head');
});

它的作用是添加一个新的 css 规则,将文本推出框外并添加背景图像

关于asp.net - jQuery 和 asp.net 不能很好地协同工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2032442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com