|
Menu principal
Google Search
LabsSphère Catégories
|
Found a new JS pattern from MSDN.One day, I was trying to detect whether an element is an element that has no close tag. var tagName = el.tagName.toLowerCase(); Well, this is not that efficient to write your program. var map = makeMap(’area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed’); Of course we can use RegExp to test it, just like many others did. var reg = /^(area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param|embed)$/i; and maybe you can find more tricks that solve the same problem with low cost, but below is the most interesting one that caught my attention. if ( tagName != “BUTTON” | “B” | “A” ){ Wait, this seems really strange to me and seems not to perform as what I was expecting.
Unfortunately, this is simply not working though I almost thought I found a new JS pattern from MSDN and was very excited about it for just about 10 seconds. It’s fun to learn JS from microsoft.
URL :
http://labs.xoofoo.org/modules/planet/view.article.php/10739
Trackback : http://labs.xoofoo.org/modules/planet/trackback.php/10739
Les commentaires appartiennent à leurs auteurs. Nous ne sommes pas responsables de leur contenu.
|