Answer the question
In order to leave comments, you need to log in
How to remove php from js?
Good day everyone. There is a code in js and php, js sends an event to different id in Google Map:
$("#card'.$id.'").each(function() {
$(this).on("mouseenter", function() {
if(infobox) {
google.maps.event.trigger(Marker['.$id.'], "click");
}
});
$(this).on("mouseleave", function() {
infobox['.$id.'].open(mapGMap, Marker['.$id.']);
});
});
<div id="card<?php echo $item->id; ?>">Текст</div>
Answer the question
In order to leave comments, you need to log in
Specify a class for the div and attach a handler to it. And id parameter.
<div class="card-item" item-id="<?php echo $item->id; ?>" id="card<?php echo $item->id; ?>">Текст</div>
<script>
$('.card-item').each(function(){
var item_id = $(this).attr('item-id');
});
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question