在JavaScript中使用Accent(jQuery)代码
Using Accent in JavaScript (jQuery) code
我在购物车脚本中有一些口音问题。这是我的Javascript代码的一部分:
//process product groups
products.each(function(gid) {
//create groups of products
var gname = this.id.replace(/_/g, ' ');
var gbutton = $('<a />',{'title':gname, 'prod_id':this.id,'href':'#'}).text(gname);
$('<li/>').append(gbutton).appendTo(groups);
//register onclick event for group link
gbutton.click(function(e) {
//make clicked group active
groups.find('.active-group').removeClass('active-group');
$(this).parent().addClass('active-group');
//hide all groups
products.css('display','none');
active_group = $('#' + $(this).attr('prod_id'), shop);
//show only active group
active_group.css({'top':0,'display':'block'});
//animate products by shifting their top position and tweening opacity
active_group.children('li').each(function(i){
$(this).css({'top':parseInt((i+settings.pageColumns)/settings.pageColumns)*settings.groupAnimationShift,'opacity':0});
$(this).delay(i*settings.groupAnimationStartDelay).
animate({'top':0,'opacity':1},settings.groupAnimationTime,settings.groupAnimationEasing);
});
//update number of pages
active_group.current_page = 1;
active_group.pages = Math.ceil(active_group.children('li').length / (settings.pageRows*settings.pageColumns));
//update page scroll
resetPageScroll();
e.preventDefault();
});
它在 HTML 中与 UL ID 链接
前任。:
<ul id="Enseignes_Résidentielles">
<li class="product" name="RD-101" price="5" minimum="4" skip="4">
<a class="product-image fancybox" href="images/product_big.jpg" title="Picture 4">
<img src="images/product_2.png" alt="Preview"/>
<div class="text-overlay">
<p class="product-heading">Description</p>
Enseignes résidentielles imprimées sur 2 panneaux 4 mm 36” x 24” collés dos à dos.
</div>
</a>
<p class="product-heading">RD-101 (Simple)</p>
<a href="#" id="test" class="product-buy">Ajouter au panier</a>
<p class="product-meta">Double de pareterre 32x24</p>
<div class="product-price">18<span class="product-currency">$</span></div>
</li>
除了购物车 DIV 中的所有功能外,当我向 UL id 添加重音和其他标点符号时,一切都在工作......如果我的 UL ID 不包含重音符号或其他 utf-8 字符,则工作正常。
知道为什么吗?知道如何解决这个问题吗?
编辑
这是现场项目... : http://danalcoimpressions.com/remax/index.html试试这个...在第一个选项卡中的任何项目中单击"Ajouter au panier"(Enseignes Résidentielles)...将鼠标悬停在购物车选项卡上,然后尝试从该类别中添加或删除项目,这将不起作用。但是在第二个选项卡(Enseignes Balcon)中尝试同样的事情,因为选项卡(UL)名称中没有重音...它将在购物车中很好地工作。
from HTML 中 id 属性的有效值是什么?
ID 和 NAME 标记必须以字母 ([A-Za-z]) 开头,后跟任意数量的字母、数字 ([0-9])、连字符 ("-")、下划线 ("_")、冒号 (":") 和句点 (".")。
我认为问题出在这段代码上:
function itemRemoveHandler(p) {
//look for item in cart
var filter = /('w+)::('w+)/.exec(p.id);
delete cart[filter[1]][filter[2]];
JavaScript 对正则表达式中的 Unicode 字符的支持很糟糕。特别是,'w
运算符无法正常工作。因此,匹配不起作用,因此delete
线中断。
我不确定该建议什么解决方法。您可以将特殊字符排除在"id"值之外,或者使用正则表达式。
编辑 — 确认确定;正则表达式应用于字符串时,与重音字符不匹配。
- 如何动态插入jquery代码
- 如何在php变量中嵌入JQuery代码
- 将 jQuery 代码添加到 Index.aspx 页面
- jquery代码在Mozilla中有效,但在其他浏览器上无效
- Jquery:代码在rails中的页面加载时未执行
- 点击facebook像素跟踪注册(JS/JQUERY代码)
- 我的jquery代码不起作用.为什么?
- 将javascript代码转换为jquery代码时出错
- 在CodeIgniter视图中将Javascript或jQuery代码作为PHP文件编写可以吗
- 按键时停止jquery代码
- 在Grails中的gsp中执行jquery代码
- 这个jquery代码是如何工作的
- 如何在加载角度函数后运行jQuery代码
- 如何使用Javascript或jQuery代码调用mousemove
- 如何使用我的Jquery代码创建委托事件侦听器
- 为什么jQuery代码段在没有IFrame的情况下可以工作,而在有IFrame时却不能工作
- 将JQuery代码转换为等效的JavaScript代码
- JQuery代码语法问题?(“不允许内联控制结构”)
- 使用一个 jquery 代码关闭多个模态
- 如何简化动画jQuery代码