How to append two classes on a single onclick I want to use .append function on 2 different classes but on a single onclick function
<script>
jQuery(document).ready(function($){
$(window).one('click', function() {
$(".am-fs__main-content").append("<b>Hello World 1</b>");
$(".am-fs__payments-sentence").append("<b>Hello World 2</b>");
});
});
</script>
But When I add Second Append It stop working !
What does "stop working" mean? Error in console? The code looks correct
@Sinnbeck not working means the 2nd append doesn't work! I think so It is a step form and I am using the second append on the last step that's why it's not working.
@Alex Fts so if you swap them, the other one works?
@Sinnbeck No it's only working on the first step on the last step, not even a single append is working.
@Alex Fts So the isnt clicking 2 classes, but why this one line does not work?
$(".am-fs__payments-sentence").append("<b>Hello World 2</b>");
@Sinnbeck I think this line is on the last step therefore it's not picking his class,
Is there any alternative way to do this?
@Alex Fts Sorry you lost me. If you move it to the top in that click method, it works or it still does not work?
@Alex Fts Show the html that has that class
You don't have an element with the class am-fs__payments-sentence. That's it.
@MichalOravec element with this class exists but on the next step of the form
@Alex Fts What does next step mean? Different page?
@Sinnbeck no it's on the same page with a modal(pop up)
@alex fts
Probably not the answer but should it not be $(window).on('click', function() { and not $(window).one('click', function() { you've got one not on
EDIT --
I've created a quick pen and it seems to work fine if I understand the question correctly so could be a HTML markup issue.
https://codepen.io/craig_codes/pen/QWrLRox
@Sinnbeck I've never come across that before, good to know
@cib88 yeah threw me off as well when I saw it for the first time
Please sign in or create an account to participate in this conversation.