1,扩展变量不输出
http://<?=$public_r['add_www_92game_net_wap']?>
2,本站搜索和淘宝搜索 <form id="_search_form" name="_search_form" method="post" enctype="multipart/form-data">
<div class="srh-inp">
<div class="srh-xl" id="searchxl">
<ul class="triggers">
<li class="selected">搜 索</li>
</ul>
</div>
<input placeholder="搜"生日礼物"试试" class="so_kw" data-type="kw" name="keyboard" id="keyboard" value="" autocomplete="off" accesskey="s" aria- expanded="true" type="text">
<input type="hidden" name="show" value="title"/>
<input type="hidden" name="tempid" value="1"/>
</div>
<input class="srh-sub so_web _check_form" url="/e/search/index.php" value="搜本站" type="button" >
<input class="srh-sub so_tb _check_form" url="http://ai.taobao.com/search/index.htm" value="搜淘宝" type="button">
<input value="mm_124697851_28976857_108636104" name="pid" type="hidden">
</form>
解决:
$("#_search_form input.srh-sub").on("click",function(){
var url = $(this).attr("url");
$("#_search_form").attr("action",url);
$("#keyboard").attr("name",$(this).hasClass("so_tb")?"key":"keyboard");
$("#_search_form").submit();
});
可以实现点击搜索了,可是仍不能按键搜索,还需js控制:
$("#keyboard").on("keyup",function(){
var url = "/e/search/index.php";
$("#_search_form").attr("action",url);
$("#keyboard").attr("name","keyboard");
$("#_search_form").submit();
});
3,判断商品是天猫的,还是淘宝的 参考:
function hasstring($source,$target){
preg_match_all("/$target/sim",$source,$strResult, PREG_PATTERN_ORDER);
return !empty($strResult[0]);
}
例子
var_dump(hasstring('萌娘百科','萌娘')); //输出true
var_dump(hasstring('萌娘百科','兄贵')); //输出false