Click here to Skip to main content
14,937,132 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am working on a leaflet map created by pure JavaScript, I have no experience in jQuery and the only solution I have found to my problem is in that format, any help on a working translation?

JavaScript
$('<h6 id="mapTitle">BikeMapCode sample</h6>').insertBefore('div.leaflet-control-layers-base');

thanks!

What I have tried:

Everything except a jQuery to JavaScript translation, which is why I'm here for some help
Posted
Updated 27-Oct-18 1:11am
v2

The best way for you to learn how to transcode jQuery to JavaScript is going to be going through the documentation for a jQ function and then finding the analog within JS. You should be able to figure out what the nuances are and go from there.

w3 schools has documentation on both. Compare and Learn
w3Schools: jQuery insertBefore() Method[^]
w3Schools: HTML DOM insertBefore Method[^]

You may also find some more at jQuery.com
.insertBefore() | jQuery API Documentation[^]
   
Not clear what the pasted code is doing, some of the HTML tag could be sanitized when you make the post. I'm guessing, the code is trying to append a div element on top of the h6 element? and the div will have a class? Anyway, the below example and reading materials should help.

Here is an example: CP_JS_insertB4 - JSFiddle[^]

Here is more reading to get you started: HTML DOM insertBefore Method[^]
   
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900