$url = $url + '&keyword=' + $val; } } else { $url = $url + '&keyword=' + $val; } $('a.search_tag').attr('href',$url); })