As in the title above: how to combine two lines in jQuery?
This is my code:
$(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 previous code, in the variable name serviceID, I concatenate hashtagmy value GETas well, and I try to put it in ALERT, and the result will be correct, but when I assign it to it .addClassdoesn’t work.
Any alternatives and solutions are greatly appreciated.
source
share