PHP Variable inside .attr String -
i can't figure syntax of placing php variable inside string. code follows:
if( /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.useragent) ) { jquery('#pinfo').attr('href','mailto:mobile@domain.com?subject=' . get_the_title() ); jquery('#pinfo').attr('class','pullup'); }; get_the_title() not being displayed , code seems break current syntax.
when use php alongside javascript, php gets executed before javascript does. write code so:
if( /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.useragent) ) { jquery('#pinfo').attr('href','mailto:mobile@domain.com?subject=<?=get_the_title()?>'); jquery('#pinfo').attr('class','pullup'); }; once browser renders page, leave javascript looks (which browser needs):
if( /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.useragent) ) { jquery('#pinfo').attr('href','mailto:mobile@domain.com?subject=my page title'); jquery('#pinfo').attr('class','pullup'); };
Comments
Post a Comment