首先,我values从 a得到所有的php array:
<?php
$user_id = get_current_user_id();
$userPostsInternal = get_user_meta( $user_id, 'save_post_internal', TRUE );
$userPostsExternal = get_user_meta( $user_id, 'save_post_external', TRUE )
?>
然后我得到这些arrays并将它们转换为JS array
var savedInternal = "<?php echo $userPostsInternal; ?>";
var savedExternal = "<?php echo $userPostsExternal; ?>";
savedInternal = savedInternal.split(',');
savedExternal = savedExternal.split(',');
然后我需要检查电流id value是否在其中js array并相应地进行:
if($.inArray(this.id, savedInternal) !== -1) {
console.log("yes");
} else {
console.log("no");
}
这是在鼠标悬停在元素上时发生的,如果我放置以下内容id是正确的,那么它不是关于this.id
console.log(this.id);
我明白了128545,这是正确的。
完整代码:
google.maps.event.addListener(circle, 'mouseover', function(e) {
<?php
$user_id = get_current_user_id();
$userPostsInternal = get_user_meta( $user_id, 'save_post_internal', TRUE );
$userPostsExternal = get_user_meta( $user_id, 'save_post_external', TRUE )
?>
var savedInternal = "<?php echo $userPostsInternal; ?>";
var savedExternal = "<?php echo $userPostsExternal; ?>";
savedInternal = savedInternal.split(',');
savedExternal = savedExternal.split(',');
$("#timeSearch").removeClass("fadeIn").addClass("fadeOut");
$(".infoBox").removeClass("fadeOut").addClass("fadeIn");
if(this.currSite == "curr" ) {
var linkGo = this.linkToPost;
var whatSite = this.currSite;
if($.inArray(this.id, savedInternal) !== -1) {
}
}
infoWindow = new google.maps.InfoWindow({content: contentString});
infoWindow.setPosition(this.getCenter());
infoWindow.open(map);
btnBoxSave(infoWindow, whatSite);
});
互换的青春