Klaus is absolutely right.

If you really really really cannot get around this invalid html then seeking
the id as an @attribute seems to work, for
example: $("[EMAIL PROTECTED]'']")
Note: the inner quotes in the example are two single quotes right next to
eachother to represent an empty string. You just need to pop your ElementId
variable into the single quotes so you'll end up with something like this:
$("[EMAIL PROTECTED]'" + ElementId + "']")

Tip: Include the tag name in the query if you can (I used a DIV in my
example) for better performance, hence not like this if possible:
$("[EMAIL PROTECTED]'']")

George


Klaus Hartl wrote:
> 
> Ashish Agrawal schrieb:
>> First, Thanks for such a great library. It damn good and fast - and most 
>> of all life saver for new bees like me.
>> 
>> Recently I fall in trouble. I had an element in my HTML that may 
>> contains blank space in its ID. The thing is I am having one asp.net 
>> <http://asp.net> based portal system where IDs are given by user on 
>> runtime that may contain spaces. Here if I use plain $("#" + ElementId) 
>> things will not work because ElementId may have "blank space" that means 
>> for jQuery engine those are 2 items passed for search.
>> 
>> Right now I have fixed it using $(document.getElementById(ElementId)) 
>> but I am really not feeling comfortable with it. Is there any other 
>> possible solution to resolve the issue?
>> 
>> Thanks,
>> Ashish Agrawal
> 
> Element ids must not have white space in it:
> http://www.w3.org/TR/html401/types.html#type-name
> 
> Scripting on top of an invalid HTML document won't make your life easier 
>   (obviously). I'd try to replace spaces given by the user to "_" in the 
> backend.
> 
> 
> -- Klaus
> 
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-get-element-when-it%27s-ID-contains-bank-space.-tf2958527.html#a8286927
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to