V
V
Valery Pavlenko2017-09-23 14:28:32
css
Valery Pavlenko, 2017-09-23 14:28:32

How to modify the function condition?

There is a script that outputs a block with the class name rsya after the 3rd h2 subheading:

<script>
$(function(){
   var insert_after = 3;
   var n =   parseInt($(".box_in h2").length);
   if (n >= insert_after){
       $($(".box_in h2")[insert_after]).after($(".rsya"));
   };
});
</script>

How to refine the function so that it does not work if the number of h2 subheadings in the document is less than 3?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ragtime Kitty, 2019-06-10
@JohnDoe116

As suggested in the comments: move the inputs themselves to the beginning of the general wrapper and change the selectors a bit:
And in the future, please post all the code in the sandbox.

R
Roman Alexandrovich, 2017-09-23
@RomReed

https://jsfiddle.net/mb4Lf1ja/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question