var s = "sum",
ispan = $("<span>").text(s).addClass(s).attr({ title: s });
ispan.insertBefore("#Button1");
var sp = $("#" + s);
alert(sp);
alert(sp.name);
here i created a span and inserted. i would like to find the id of the same span.
i mean the same – .text(s)
How can i find the text or id of this span ..?
If you’re creating it without an id, it won’t have an id. You can specify an ID when you create it via attr:
Change ‘MYSPANID’ to something appropriate.
Once you have an id on the span you can easily select it later (and grab its text) with an id selector:
or
as appropriate.