开发者

How do you use .js id= multiple times?

I have this code in functions.js

$("a#example2").fancybox({
'overlayShow' : false,
'transitionIn' : 'elastic',
transitionOut' : 'elastic'

and it works but brings up my only errors while validating as HTML5. This is because I am using six

id="example2"

instances in my gallery and it flags for multiple use. When I dug up the templates for this, it had example1, example2 etc. and I just converted all to the one I like. This is for a gallery on my website at http:开发者_StackOverflow//www.shaneofalltrades.com. Thanks!


id= is intended to be an identifier unique to the whole DOM. class= allows you to group elements by a common identifier.

HTML:

<div class="someClass">Content</div>

CSS:

.someClass
{
  background:transparent;
  color:#990000;
}

.someClass div { ... }

jQuery:

$('.someClass').html()
$('.someClass div').html()


Short answer, you don't. That's what classes are for.

<a class="fancy">....

$('.fancy').fancybox(.....


You can't. You should be using class="example2" instead.

So your selector will look like: $("a.example2").fancybox({...})

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜