Just like the title above: how to concatenate two strings in JQuery?
This is my code so far:
$(document).ready(function(){
serviceName = '<?=$_GET['services'] . ".php";?>';
serviceID='<?= "#" .$_GET['services'];?>';
serviceClass = '<?=$_GET['services'];?>';
if (serviceName != "") {
alert(serviceID);
$('.main_content').load(serviceName);
$(serviceID).addClass("it");
}
});
As you can see in my above code, in variable name serviceID
, I am concatenating hashtag
and my GET
value and I try to put it on ALERT and the result is correct, but when I assign it to .addClass
it’s not working.
Any alternatives and solution is much appreciated.
alert($(serviceID).length)
, to see if you did get the element, if it alert a number greater than 0. – Reigel Apr 29 '14 at 9:50