tags:

views:

40

answers:

5

I am creating a set of dynamic divs

Let div id is div1 div2 div3 etc

in my function for getting div id am concatinating

var divid= 'div'+1
var divid= 'div'+2 

etc.

if i call jquery slide down

$('#div1').slideDown('slow'); 

Its working ,but if i use

$('#divid').slideDown('slow'); 

Its not working . Why? divid is having same value.. What i am missing??

+3  A: 

In the example you show:

$('#divid')

divid is interpreted as a literal string, not a variable.

What you are probably looking for is

$('#'+divid)
Pekka
A: 

jQuery is looking for a div with the id 'divid', that's what $('#divid') does. What you want is to use the variable divid to search, you need to do $('#'+divid).

Rocket
A: 

divid is string not variable in your case.

$("#"+divid).slideDown("slow");
Anpher
A: 

Change

$('#divid').slideDown('slow'); 

to

$('#'+divid).slideDown('slow'); 

String literal v.s variable issue

sjobe
exactly...hmm.. why i miss that... sad but true
zod
A: 
var divid= 'div'+1
var divid2= 'div'+2 


jQuery('#'+divid).slideDown('slow'); 
you have to pass proper selector to jquery
Praveen Prasad