任何人都知道如何将此jquery片段转换为可用的纯JavaScript代码? [英] Anyone know how to convert this jquery snippet into workable pure javascript code?

查看:61
本文介绍了任何人都知道如何将此jquery片段转换为可用的纯JavaScript代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个由纯JavaScript创建的传单地图,我没有jQuery的经验,我找到的唯一解决方案是我的问题就是这种格式,对工作翻译有什么帮助吗?



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?

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



谢谢!



我尝试过什么:



除jQuery到JavaScript之外的所有内容,这就是为什么我在这里寻求帮助


thanks!

What I have tried:

Everything except a jQuery to JavaScript translation, which is why I'm here for some help

推荐答案

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



谢谢!


我尝试了什么:



除了jQuery到JavaScript之外的所有内容,这就是为什么我在这里为了一些帮助


thanks!

What I have tried:

Everything except a jQuery to JavaScript translation, which is why I'm here for some help


你学习如何将jQuery转码为JavaScript的最佳方法是通过jQ函数的文档,然后在JS中找到模拟。你应该能够弄清楚那些细微差别是什么,并从那里开始。



w3学校有两个文件。比较和学习

w3Schools:jQuery insertBefore()方法 [ ^ ]

w3Schools:HTML DOM insertBefore Method [ ^ ]



您还可以在jQuery.com找到更多内容

.insertBefore()| jQuery API文档 [ ^ ]
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[^]


不清楚粘贴的代码在做什么,在发布帖子时可以清理一些HTML标记。我猜,代码试图在h6元素的顶部附加一个div元素?和div将有一个类?无论如何,下面的例子和阅读材料应该有所帮助。



这是一个例子: CP_JS_insertB4 - JSFiddle [ ^ ]



这里有更多内容可以帮助您入门: HTML DOM insertBefore方法 [ ^ ]
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[^]


这篇关于任何人都知道如何将此jquery片段转换为可用的纯JavaScript代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆