Tag: href

jQuery this.href字符串比较不起作用

我有一个简单的jQuery脚本,我正在尝试构建,但我不能让href字符串比较返回true: Click Me​ 我的脚本如下: $(‘.test’).click(function() { if ($(this).href == “https://stackoverflow.com/Services/Cloud-Hosting”) { alert(‘hi’); } else { alert(‘no’); } });​ 即使href是相同的,我仍然会收到’不’的警报。 我错过了什么?

获取url路径并在li上添加活动类

我尝试抓住url路径,然后在li示例中添加活动类:www.mysite.com/?p = xxxx x将根据用户点击的链接而改变 我试过这个: Åbningstider Butikker Det sker Nyhedsbrev Find vej var text = window.location.href.match(/http:\/\/www\.mysite\.com\/(.+)/)[1].replace(/_/g,’ ‘); $(“#nav li”).filter(function() { return $.text([this]) == text; }).addClass(“active”); 但没有任何反应。 我做错了什么?

jQuery – 识别并标记textarea中的链接

我有一个textarea 我需要一个脚本来突出显示在textarea中写的链接,将它们存储在变量(数组)中以便以后处理并删除所有html标记。 从twitter上的tweet-box知道这种行为。 所以内容可能是 看看我今天在www.stackoverflow.com上找到的内容! 在这种情况下,应该突出显示www.stackoverflow.com(包含在 fe中),而不是“!”。 你会如何用jQuery做到这一点?

将urlVariable附加到下一页的链接

如何设置页面以将urlVariable附加到其链接中? 例如,我有3个不同的页面,并且都链接到同一页面,例如 receiver.html 首页链接: receiver.html?sender=1 第二页链接: receiver.html?sender=2 第三页链接: receiver.html?sender=3 当单击第一页时,它会将用户发送到内部有许多外向链接的receiver.html,并且脚本会根据上面的三个页面将变量附加到其所有外发链接中? receiver.html outgoinglink.html?sender=1 outgoinglink2.html?sender=1 outgoinglink3.html?sender=1 如果使用第二页,则receiver.html将追加 ?sender=2 在其内部的所有链接等等…

如何使用jquery将HTML标题文本复制/克隆到href mailto主题行?

我想抓住h1标题文本并将其添加到mailto的主题行。 我得到了这个。 我只是不知道如何用正确的表达来代替’用标题替换’。 克隆是否会朝着正确的方向发展? 谢谢参观! Headline Email Link $(‘#mailme a’).each(function() { $(this).attr(‘href’, $(this).attr(‘href’) + ‘replace this with the h1 headline’); }); 感谢所有投入解决方案的人。 我在一个简单的HTML页面模板中使用它,其中客户端正在编辑内容但没有HTML技能。 每个内容页面都有一个电子邮件按钮,该按钮使用以下脚本之一根据页面标题自定义电子邮件主题行。 我希望其他人也会觉得这很有用。

如何在jquery中禁用链接

我的页面有一个链接 Hyper link 我想在用户点击链接时打开一个对话框。 我想禁用链接而不删除他的href事件或属性 表示html没有变化 然后 当用户点击链接然后打开一个对话框 如果jquery没有加载或有错误导致直接打开链接。 我怎么能做到这一点。

如何使用每个文章过滤attr href中的文章并查找用法? 简单的标签列表

我有很多div.articles和那篇文章; 我有标签列表。 我正在尝试隐藏文章div,但没有得到href =’#myFilter’。 到达href我没有问题,我的问题是在没有创建jQuery冲突的情况下达到它的parent()。 这是jsFiddle示例来检查。 jQuery的 //trying to hide which don’t got a href ‘#/news’ var news = ‘#/news’; $(‘.article a’).each(function() { var category = $(this).attr(‘href’); if ( category === news ) {//select only articles got #/news href in it //$(this).parent().parent().parent().show();//trying to reach article $(this).show(); }else{ //$(this).parent().parent().parent().hide();//this way hides all articles $(this).hide();//this works only […]

PHP:用querystring替换匹配的文本

我有一个像经文这样的缩写列表: Mt=80 Lu=81 Rv=92 Nd=95 etc. 我目前正在jquery转换这些链接: Mt 5: 2 Nd 14: 25 并使它们如下: Mt 5: 2 Nd 14: 25 用于此的脚本是: $(document).ready(function() { $(“a[href=’page.php’]”).each(function(index, element){ href = $(element).attr(‘href’); // get the href text = $(element).text().split(‘ ‘); // get the text and split it with space $(element).attr(‘href’, href + “?book=” +$.trim(text[0])+”&chapter=”+$.trim(text[1].slice(0,-1))+”&vmin=”+$.trim(text[2])); //create desired href and replace […]

Jquery,从点击获取url并传递给对话框中的确认按钮

我有这个jquery代码: $(“#deletec-box”).dialog({ autoOpen: false, resizable: false, height:230, modal: true, buttons: { “Confirm”: function() { window.location = ‘hrefurlfromclick’; $(this).dialog(“close”); }, Cancel: function() { $(this).dialog(“close”); } } }); $(“#deletec-confirm”).click(function() { $(“#deletec-box”).dialog(“open”); return false; }); 然后在页面中我有一个调用对话框的链接: Delete 我的问题是如何获得href的值,如果该人确认它加载了他们最初点击的链接?

jQuery:向URL添加字符串

我正在使用这段代码从点击的链接中获取url: var url = $(this).find(‘a’).attr(‘href’); 我想在该url中添加一个字符串。 例如,我当前的url是: http://mydomain.com/myarticle 我想做到: http://mydomain.com/myarticle-chinese 我应该在初始代码行中添加什么来实现这一目标? 我很感激你的建议! 附录:非常感谢! 四个人几乎同时得到了答案,所有四个人都得到了一个有用的答案。 我希望我能接受所有这四个!