Home > Web Front-end > HTML Tutorial > jquery 语句如何合并?_html/css_WEB-ITnose

jquery 语句如何合并?_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:02:17
Original
931 people have browsed it

$('li').click(function(){
var li_link=$(this).attr('_src');
if(li_link&&li_link!='undefined'){location.href=li_link;}
})
$('span').click(function(){
var li_link=$(this).attr('_src');
if(li_link&&li_link!='undefined'){location.href=li_link;}
})
$('div').click(function(){
var li_link=$(this).attr('_src');
if(li_link&&li_link!='undefined'){location.href=li_link;}
})


我应该如何合并这些语句?谢谢,把它变为一个。


回复讨论(解决方案)

$('div,li,span').click(function(){
var li_link=$(this).attr('_src');
if(li_link&&li_link!='undefined'){location.href=li_link;}
})

$('div,li,span').click(function(){
var li_link=$(this).attr('_src');
if(li_link&&li_link!='undefined'){location.href=li_link;}
})



原来可以这么用,涨知识了。。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template