-2
我想单击内联链接时运行脚本,或者输入URL http://site.com/index.php#comment。与链接到评论时在reddit上发生的情况类似。当内联链接“#”被点击或输入URL时,如链接到reddit注释时,如何运行jQuery命令
我该怎么做?
我想单击内联链接时运行脚本,或者输入URL http://site.com/index.php#comment。与链接到评论时在reddit上发生的情况类似。当内联链接“#”被点击或输入URL时,如链接到reddit注释时,如何运行jQuery命令
我该怎么做?
我会给你idea..Suppose要处理所有一个标签
HTML
<a href="http://site.com/index.php#comment">Link<a>
的JavaScript
$('a').click(function(event){
event.preventDefault();
var url = $(this).attr('href');
var lastPart = url.split('#')[1];
if(lastPart=== 'comment') {
//do something
} else if(lastPart === 'post') {
//do something
}
});