$(abc).def().ghi()
use
var x=$(abc);
x.def();
x.ghi();
Do the same with the css: set each property seperately. This will allow you to identify exactly which part is causing problems.
Blair
On 10/27/06, smeranda <[EMAIL PROTECTED]> wrote:
Thanks for your help!
I tried your code, but I received a 'syntax error' on the first .find line.
I don't see anything that looks out of the ordinary....
Blair McKenzie-2 wrote:
>
> Take this with a grain of salt (I haven't tested it), but this should
> work:
>
> $("majorname", xml).each(function(i){
> var $this = $(this); // Wrap this item in jQuery
>
> // Notice that all of these methods are chained together. For
> debugging you would probably separate them out
> // 1) $("<tag></tag>") - When the selector string is actually an
> element descriptor, jQuery creates that element, and returns it
> // 2) find() - searches again in the context of the origonal jQuery
> array
> // 3) css() - takes a hash of css properties and their values, and
> applies them to the jQuery array
> // 4) end() - closes the last context search, and returns the the
> previous result set
> // 5) appendTo() - performs a jQuery search, then moves the current
> array of elements to the result
> $("<li><label><span>"+$this.text()+"</span></label><input
> name='"+$this.text()+"' value='3'></input><span
> class='currenttotal'></span></li>")
> .find("label").css({ 'display':'-moz-inline-box',
> 'textAlign':'left' })
> .find("span").css({ 'display':'block', 'width' = '120px'
> }).end()
> .end();
> .appendTo("#appointmentList");
> });
>
>
>
> On 10/27/06, smeranda <[EMAIL PROTECTED] > wrote:
>>
>>
>> I am trying to add a class (.currenttotal) to a dynamically generated
>> span
>> element. How can I do this?
>>
>> Basically, I am pulling an xml file and using the information to create
>> an
>> interface. I need to add the .currenttotal class to the registeredSpan.
>> Any
>> ideas?
>>
>> $("majorname", xml).each(function(i){
>> var listItem = document.createElement( 'li' );
>> var listLabel = document.createElement( 'label' );
>> listLabel.style.display = '-moz-inline-box';
>> listLabel.style.textAlign = 'left';
>> var labelSpan2 = document.createElement ( 'span' );
>> labelSpan2.style.display = 'block';
>> labelSpan2.style.width = '120px';
>> labelSpan2.innerHTML = $(this).text();
>> var listInput = document.createElement( 'input' );
>> listInput.name = $(this).text();
>> listInput.value = '3';
>> var registeredSpan = document.createElement ( 'span' );
>> $(registeredSpan).addClass("currenttotal"); //This
>> doesn't
>> work.
>> listLabel.appendChild( labelSpan2 );
>> listItem.appendChild( listLabel );
>> listItem.appendChild ( listInput );
>> listItem.appendChild( registeredSpan );
>> $("#appointmentList").append( listItem );
>> });
>>
>> If there is a better way to write the above code, I'm open to
>> suggestions!
>> --
>> View this message in context:
>> http://www.nabble.com/Adding-class-to-dynamic-element-tf2517168.html#a7020780
>>
>> Sent from the JQuery mailing list archive at Nabble.com.
>>
>>
>> _______________________________________________
>> jQuery mailing list
>> [email protected]
>> http://jquery.com/discuss/
>>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context: http://www.nabble.com/Adding-class-to-dynamic-element-tf2517168.html#a7030235
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
