JS基础教程——JavaScript基础知识(1.3对象-1.3.3对象的转换)

2013-12-20 liyangweb.com 李杨 JavaScript

jQuery对象是通过jQuery包装DOM后产生的对象。jQuery对象可以使用jQuery里的方法,但是不能使用DOM方法。DOM对象是JavaScript固有的一些对象操作。DOM对象能使用JavaScript固有方法,但是不能使用jQuery里的方法。因此,对象间的转换就成为了一种必要。

1.DOM对象转换为JQuery对象

对于一个固有的DOM对象,只需要用$()把DOM对象包装起来。就可以获取jQuery对象,代码如下:

var x = docuen.getElementById("x");    //DOM对象
var $x = $(x);    //jQuery对象,前提是当前页面已经引入了JQuery

经过转换,就恶意将次DOM对象当作jQuery对象来使用了。

2.jQuery对象转换为DOM对象

在一些必要的情况下,jQuery对象转换成DOM对象是必要的,在转换过程中有两种方式进行选择:[index]方式和get(index)方式。

(1)jQuery对象是一个数据对象,可以通过[index]的方法来得到相应的DOM对象,代码如下:

var $v=$("#v");    //jQuery对象
var v=$v[0];    //DOM对象

(2)jQuery本身提供的,通过.get(0)方法得到相应的DOM对象,代码如下:

var $v = $("#v");   //jQuery对象
var v = $v.get(0);    //DOM对象

通过以上方法,可以任意的相互转换jQuery对象和DOM对象。

关于jQuery的详细介绍,我将在后面的博客中做单独讲解。敬请关注~~~

标签: JavaScript JS基础教程

评论:

votuongluan
2019-02-01 09:38
<a href="http://www.heslaatours.com/nike-flyknit-lunar-2-canada-program-skof">nike flyknit lunar 2 canada program</a> <a href="http://www.prostekrasna.com/zx-flux-grey-and-silver-skob">zx flux grey and silver</a> <a href="http://www.altharmony.com/womens-dolphins-hat-uk-hatd">womens dolphins hat uk</a> <a href="http://www.cosmicupcake.com/black-womens-nike-sb-stefan-janoski-max-shoes-runninge">black womens nike sb stefan janoski max shoes</a> <a href="http://www.btmtecled.com/nike-hyperdunk-2015-mid-marr%C3%B3n-oro-schuhea">nike hyperdunk 2015 mid marr贸n oro</a> <a href="http://www.torcgunstore.com/nike-zoom-clear-out-himmelblau-gold-scarpeb">nike zoom clear out himmelblau gold</a>
votuongluan http://www.votuongluan.com/
warthogrugby
2019-01-24 14:48
<a href="http://www.femmedeguinee.com/nike-huarache-high-womens-gold-pink-skod">nike huarache high womens gold pink</a> <a href="http://www.autosasart.com/how-to-tell-authentic-burberry-scarf-scarfr">how to tell authentic burberry scarf</a> <a href="http://www.pcwolftech.com/new-york-yankees-new-era-baseball-cap-used-hatg">new york yankees new era baseball cap used</a> <a href="http://www.poteputi.com/nike-hypershift-weight-skox">nike hypershift weight</a> <a href="http://www.minsonphoto.com/purple-red-mens-nike-zoom-winflo-3-shoes-shoesb">purple red mens nike zoom winflo 3 shoes</a> <a href="http://www.sandeneuhofer.com/billig-nike-kwazi-action-dam%C3%A4nner-gold-runningb">billig nike kwazi action dam盲nner gold</a>
warthogrugby http://www.warthogrugby.com/
duboismantels
2019-01-24 09:33
<a href="http://www.candacebenson.com/asics-gel-hyper-33-s%C3%B8lv-sort-schuhee">asics gel hyper 33 s酶lv sort</a> <a href="http://www.kodakid.com/mujeres-nike-zoom-pegasus-32-verde-rosado-butyd">mujeres nike zoom pegasus 32 verde rosado</a> <a href="http://www.brantfordpark.com/nike-air-max-bw-imperial-bl%C3%A5-island-obuvc">nike air max bw imperial bl氓 island</a> <a href="http://www.landsmanbook.com/adidas-springblade-drive-2.0-grau-wei%C3%9F-scarpee">adidas springblade drive 2.0 grau wei脽</a> <a href="http://www.moviestellar.com/nike-air-max-schwarz-blau-obuvd">nike air max schwarz blau</a> <a href="http://www.djprofi.com/nike-zoom-winflo-2-negro-corriendo-zapatos-list-chaussuresg">nike zoom winflo 2 negro corriendo zapatos list</a>
duboismantels http://www.duboismantels.com/
umuttekelbayi
2019-01-16 11:04
<a href="http://www.heslaatours.com/b%C3%B8rn-nike-light-up-sko-s%C3%B8lv-r%C3%B8d-kurpesa">b酶rn nike light up sko s酶lv r酶d</a> <a href="http://www.prostekrasna.com/air-max-90-2015-colorways-sneakerb">air max 90 2015 colorways</a> <a href="http://www.altharmony.com/a-buon-mercato-nike-air-max-lunar-1-femminile-bianca-shoesg">a buon mercato nike air max lunar 1 femminile bianca</a> <a href="http://www.cosmicupcake.com/golden-state-warriors-snapback-mitchell-and-ness-hats">golden state warriors snapback mitchell and ness</a> <a href="http://www.btmtecled.com/barato-nike-shox-current-mujeres-rojo-sneakerf">barato nike shox current mujeres rojo</a> <a href="http://www.torcgunstore.com/nike-roshe-run-verde-floreale-obuvc">nike roshe run verde floreale</a>
umuttekelbayi http://www.umuttekelbayi.com/
fotodardo
2019-01-10 19:33
<a href="http://www.brentgattis.com/asics-gel-sendai-2-viola-rosso-butyf">asics gel sendai 2 viola rosso</a> <a href="http://www.lfptrade.com/alle-hvid-polo-shirt-polou">alle hvid polo shirt</a> <a href="http://www.phihochwei.com/nike-free-tr-fit-gituttio-bianca-chaussuresf">nike free tr fit gituttio bianca</a> <a href="http://www.pobert.com/nike-air-max-90-vt-colorful-gr%C3%B8n-brun-scarpef">nike air max 90 vt colorful gr酶n brun</a> <a href="http://www.qrsdeals.com/lebron-james-black-finals-jersey-nfls">lebron james black finals jersey</a> <a href="http://www.taxhelpcentre.com/ralph-lauren-jumpers-nero-verde-polot">ralph lauren jumpers nero verde</a>
fotodardo http://www.fotodardo.com/
masadablog
2019-01-07 07:37
<a href="http://www.undercoverapp.com/kd-7-bad-apple-golden-sneakere">kd 7 bad apple golden</a> <a href="http://www.johnshoots.com/nike-new-york-jets-5-christian-hackenberg-green-stitched-elite-rush-jersey-nfle">nike new york jets 5 christian hackenberg green stitched elite rush jersey</a> <a href="http://www.phihochwei.com/orange-womens-nike-street-gato-ac-shoes-shoesc">orange womens nike street gato ac shoes</a> <a href="http://www.realtyindubai.com/air-jordan-10-steel-amazon-skof">air jordan 10 steel amazon</a> <a href="http://www.oneusabank.com/billig-nike-suketo-dam%C3%A4nner-lila-sportse">billig nike suketo dam盲nner lila</a> <a href="http://www.filoxenos.com/nike-cortez-maroon-mens-nike-runningd">nike cortez maroon mens nike</a>
masadablog http://www.masadablog.com/
fixlupusnow
2019-01-07 06:33
<a href="http://www.daunkatuk.com/nike-free-flyknit-4.0-caff%C3%A8-butya">nike free flyknit 4.0 caff猫</a> <a href="http://www.fjernskjegget.com/nike-huarache-ultra-cachi-duck-obuvd">nike huarache ultra cachi duck</a> <a href="http://www.pharmacypartd.com/air-jordan-aero-mania-lila-scarpea">air jordan aero mania lila</a> <a href="http://www.sobresazucar.com/maschio-salomo-s-lab-xt-rosso-argento-scarpef">maschio salomo s lab xt rosso argento</a> <a href="http://www.agivla.com/air-jordan-1-retro-oro-medal-of-obuvd">air jordan 1 retro oro medal of</a> <a href="http://www.avmbulten.com/nike-air-max-95-iridescent-for-verkauf-houston-scarpea">nike air max 95 iridescent for verkauf houston</a>
fixlupusnow http://www.fixlupusnow.com/
cundinamarca
2019-01-04 14:33
<a href="http://www.bursatiket.net/nike-flyknit-air-max-sensor-for-salg-chaussuresf">nike flyknit air max sensor for salg</a> <a href="http://www.buxpix.net/nike-air-max-zero-marina-militare-bianca-obuvc">nike air max zero marina militare bianca</a> <a href="http://www.buyggauto.net/nike-kd-9-sort-and-hvid-quartz-kurpesb">nike kd 9 sort and hvid quartz</a> <a href="http://www.carlinandcompany.net/nike-lunar-hyperdunk-2013-venta-kurpese">nike lunar hyperdunk 2013 venta</a> <a href="http://www.carrymebike.net/nike-air-force-1-mid-gr%C3%B8nn-gr%C3%A5-kurpesd">nike air force 1 mid gr酶nn gr氓</a> <a href="http://www.casatienda.net/jordan-11-gamma-bleu-keychain-scarped">jordan 11 gamma bleu keychain</a>
cundinamarca http://www.cundinamarca.net/
sateambeast
2019-01-04 08:24
<a href="http://www.evorewards.com/ralph-lauren-herren-long-sleeve-linen-shirt-polot">ralph lauren herren long sleeve linen shirt</a> <a href="http://www.kfmimarlik.com/nike-mens-anthony-zettel-limited-camo-jersey-detroit-lions-nfl-69-2018-salute-to-service-nflz">nike mens anthony zettel limited camo jersey detroit lions nfl 69 2018 salute to service</a> <a href="http://www.larozena.com/nike-kyrie-2-naranja-rosado-kurpesc">nike kyrie 2 naranja rosado</a> <a href="http://www.lebosmartlipo.com/lebron-james-black-pride-swingman-jersey-nflx">lebron james black pride swingman jersey</a> <a href="http://www.mobilsevgili.com/asics-gel-noosa-tri-8-negro-confetti-kitchen-obuvd">asics gel noosa tri 8 negro confetti kitchen</a> <a href="http://www.ochapan.com/asics-gel-noosa-tri-10-brun-gr%C3%A5-scarped">asics gel noosa tri 10 brun gr氓</a>
sateambeast http://www.sateambeast.com/
youtubetune
2019-01-03 17:38
<a href="http://www.supermarketes.com/air-jordan-future-brot-blau-obuvf">air jordan future brot blau</a> <a href="http://www.texastribal.com/nike-zoom-vomero-kvinners-rosa-himmelen-bl%C3%A5-kurpesa">nike zoom vomero kvinners rosa himmelen bl氓</a> <a href="http://www.donareseguros.com/nike-kobe-5-arancia-oro-kurpese">nike kobe 5 arancia oro</a> <a href="http://www.frozentissue.com/herre-ralph-lauren-tank-top-r%C3%B8d-hvid-poloz">herre ralph lauren tank top r酶d hvid</a> <a href="http://www.lampenloft.com/nike-lunarglide-6-lyser%C3%B8d-and-hvid-scarpeb">nike lunarglide 6 lyser酶d and hvid</a> <a href="http://www.notasoficina.com/denver-broncos-connor-mcgovern-womens-limited-orange-nike-jersey-60-nfl-rush-vapor-untouchable-nfls">denver broncos connor mcgovern womens limited orange nike jersey 60 nfl rush vapor untouchable</a>
[url=http://www.youtubetune.com/]youtubetune[/url]
rawhouseibiza
2018-12-30 04:15
<a href="http://www.ucllnl.com/nike-ash-womens-cameron-wake-backer-nfl-91-miami-dolphins-pullover-hoodie-nflw">nike ash womens cameron wake backer nfl 91 miami dolphins pullover hoodie</a> <a href="http://www.ugurcafe.com/air-jordan-future-mint-gr%C3%B8nn-hvit-chaussuresa">air jordan future mint gr酶nn hvit</a> <a href="http://www.destinyrail.com/air-jordan-5-tout-blanc-2015-butya">air jordan 5 tout blanc 2015</a> <a href="http://www.dinerwarela.com/kyrie-1-the-dream-for-vente-butyd">kyrie 1 the dream for vente</a> <a href="http://www.kalaycioto.com/air-jordan-10-blanco-negro-rojo-flag-obuvg">air jordan 10 blanco negro rojo flag</a> <a href="http://www.krystaltls.com/air-jordan-7-retro-j2k-for-vente-houston-tx-kurpesa">air jordan 7 retro j2k for vente houston tx</a>
rawhouseibiza http://www.rawhouseibiza.com/

发表评论:

Powered by emlog 冀ICP备13011830号-1