Tag: 包含

jQuery Xpath选择器,用于选择id包含’sometext’的元素

我在aspx页面中有一个listbox元素,其id是attributesList。 我想选择这个元素来跟踪它的更改事件,但我无法直接选择它的id,因为asp.net在运行时更改了它的id。 它的id,attributesList变为ctl00_adminPlaceHolder_attributesList。 所以我想要做的是使用“包含”xpath表达式来选择元素。

交叉请求出错:“Access-Control-Allow-Origin不允许原点”?

我正在尝试从另一个网站加载内容: $(‘#include-from-outside’).load(‘http://lujanventas.com/plugins/banner/index.php&callback=?’); 但是我收到了这个错误: XMLHttpRequest cannot load http://lujanventas.com/plugins/banner/index.php&callback=?. Origin http://lventas.com is not allowed by Access-Control-Allow-Origin. 我怎样才能防止它发生?

jQuery从Date提取年份并将类添加到Parent

我正在寻找为div列表创建一个同位素filter,因此想要通过从显示的日期中提取’Year’然后将其作为类添加到父容器/ div来添加一年的类到父容器/ div div( .publication ) 现在我正在使用一种非常基本的方法来查看div是否包含特定年份然后单独指定一年: HTML 15/3/2017 15/3/2016 码 jQuery(‘div[class*=”publication-date”]:contains(“2020″)’).closest(‘.publication’).addClass(‘2020’); jQuery(‘div[class*=”publication-date”]:contains(“2019″)’).closest(‘.publication’).addClass(‘2019’); jQuery(‘div[class*=”publication-date”]:contains(“2018″)’).closest(‘.publication’).addClass(‘2018’); jQuery(‘div[class*=”publication-date”]:contains(“2017″)’).closest(‘.publication’).addClass(‘2017’); jQuery(‘div[class*=”publication-date”]:contains(“2016″)’).closest(‘.publication’).addClass(‘2016’); jQuery(‘div[class*=”publication-date”]:contains(“2015”)’).closest(‘.publication’).addClass(‘2015’); 这种方法的问题在于,如果我们低于2015年或2020年以上,则不会分配任何课程。 如果我们可以爆炸日期并提取课程的年份,那么这将继续逐年进行?

隐藏包含特定字符串的div

我一直在尝试使用本网站上建议的其他解决方案来隐藏包含特定字符串的div,但是没有一个工作(很可能是因为我对jQuery缺乏经验) 我想完全隐藏所有div(在这个例子中)包含字符串’zynthesized’ zynthesized 0 4 从我所看到的东西 $(‘.photos-wrapper:contains(“zynthesized”)’).hide() 应该最接近我的需要,但我没有运气。 任何帮助都会很棒!

用javascript和jquery动态包含一个php文件

我想稍后(动态)包含一个php文件,而不是在顶部。 所有这个文件都是从服务器获取一些内容并将其存储在我稍后在jquery中使用的javascript变量中。 基本上当你点击链接时,我得到信息,然后显示它以节省资源,因为有许多链接可能没有使用。 我应该只做$(“body”).load(“phpfile.php”); ? 这应该工作,但我试图找到一个更正确的方式,因为它与身体的html标签无关。

jQuery检查输入文本是否包含特定文本

如果输入文本字段包含“ @twitter.com ”,则希望将文本附加到div 。 目前有以下但仅适用于test=151516058@twitter.com ,有何建议? var test = jQuery(‘input[name$=”user_email”]’).val(); if(test == “@twitter.com”){ jQuery(“.iump-clear”).append(‘Please update your email address’); }

jQuery.contains()无法正常工作

在下列情况下我应该得到“警报”,但我没有得到任何“警报”。 我正在尝试一个简单的jQuery.Contains()示例。 $(document).ready(function() { var alpha = $.contains(‘body’,’p’) { alert(alpha); }); This is a paragraph.

添加id并使用它的jquery脚本不起作用

我正在尝试使用我的键盘使用id单击按钮。 对于某些按钮,我必须设置ID,这实际上是有效的。 但是一旦我尝试将键盘用于我设置id的按钮,它就无法工作。 我没有收到任何错误,因为添加id到元素工作,我有点困惑为什么我不能在代码中使用新的set id。 //setting id for first button (works) $( “a:contains(‘Im Verband freigeben’)” ).attr(‘id’, ‘freigabe-verband’); //setting id for second button (works aswell) $( “a:contains(‘Vorheriger Einsatz’)” ).attr(‘id’, ‘vorheriger-einsatz’); $( document ).keydown(function(e) { if (e.keyCode == 39) { //works, id is available, not set by me $(“#alert_next”).click(); } else if (e.keyCode == 38){ // doesn’t […]

jQuery val()indexOf无法正常工作

如果输入值包含某个单词但尝试做某事但这不起作用: var formMain = $(‘#MainForm :input[name=”Search”]’); if ((formMain).value.indexOf(‘word’) >= 0) { alert(‘HAS THIS WORD IN IT!’); 示例表格:

使用contains()进行页内搜索以显示/隐藏div内容

我正在尝试在我的常见问题解答页面添加搜索function,我绝对卡住了。 我想要的是一个文本框,用户输入一个关键字(或多个单词),为关键字运行jquery,并为所有相关答案设置display:block。 到目前为止我所拥有的是: Keyword(s): This is the first software question and answer. This is the first hardware question and answer. function searchFunction() { var searchTerm = document.searchBox.keyword.value; $(” :contains(‘”+searchTerm+”‘)”).addStyle(“display:block”); }