1
I have this HTML snippet that is called on some screens when necessary (clicking it opens an iframe inside the HTML):
<a href="#" class="tour-360" id="tour-360-{{unit.hash}}" data-toggle="modal" data-target="#modal-tour-360">
<h3 class="title-360">
360º Tour {{ unit.title }}
<small>Visualize sua unidade</small>
</h3>
</a>
Depending on {{Unit.hash}}, instead of being href="#" and opening this iframe, I need to take the user to an external URL, open a link in another tab. It would be something like that(just a non-functional example to explain):
<script type="text/javascript">
var url360 = '#';
if('{{unit.hash}}' == 's-j-dos-campos'){
url360 = 'https://www.aurlqueeuquiser.com';
}
</script>
<a href="<script type="text/javascript"> alert(url360); </script>" class="tour-360" id="tour-360-{{unit.hash}}" data-toggle="modal" data-target="#modal-tour-360">
<h3 class="title-360">
360º Tour {{ unit.title }}
<small>Visualize sua unidade</small>
</h3>
</a>
How to do it? I need all the change to be done inside this HTML, I can’t put external files or anything like that.
It will only be done with that element that has the class
tour-360
?– Jorge.M
That, just his link that changes
– caiocafardo
Vc can change attributes with jQuery this way:
$(".tour-360").attr("href", url360);
– Sam