jQuery在选择器中带有英镑符号 [英] Jquery having pound sign in the selector

查看:106
本文介绍了jQuery在选择器中带有英镑符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查一个隐藏字段是否具有值,并且该隐藏字段的ID包含井号,当我使用jquery获取其值时会抛出该错误,因为起初不允许井号只出现一次在ID之前.我必须将井号转换为ASCII代码还是有其他处理方法?

I want to check if a hidden field has a value or not and the id of the hidden field contains a pound sign, when I use jquery to get its value it throws because the pound sign is not allowed only one time at first before the id. Do I have to convert the pound sign to ASCII code or is there any other way to deal with it?

有人可以帮忙吗?

var v = $('#ddlSort1#').val();

推荐答案

尝试一下:

   var v = $('#ddlSort1\\#').val();

OR

   var v = $('input[id$="#"]').val();

这篇关于jQuery在选择器中带有英镑符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆