【发布时间】:2013-08-18 18:07:52
【问题描述】:
我验证图像路径是图像路径还是其他路径。如果是图像,则将特定的 href 值替换为 # 但 # 值会影响所有链接。如何将图片链接替换为#
jQuery(document).ready(function($) {
$("a").each(function(i, el) {
var href_value = el.href;
if (/\.(jpg|png|gif)$/.test(href_value)) {
jQuery('a').prop('href', '#');
}
});
});
这里是
任何建议都会很棒。
【问题讨论】:
-
jQuery(el).prop('href', '#');而不是jQuery('a').prop('href', '#');
标签: javascript jquery image href prop