Skip to main content

Bug Tracker

Side navigation

#14502 closed bug (notabug)

Opened October 31, 2013 01:49PM UTC

Closed November 07, 2013 01:03AM UTC

Long id Names With Periods Don't Get Selected

Reported by: jdosstech@gmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:
Description

In the following code if will have a value like "com.prodeasystems.apps.Settings". Read the code below and you will see that jquery can not select the element with that id but base javascript can.

$('#parental_apps_content').append('<div id="' + this.symbolicname + '_ON"

class="parental_control_on"><img src="https://' + current_jid + '/' +

this.approot + this.iconrc + '" /></div>');

$('#parental_apps_content').append('<div id="' + this.symbolicname + '_OFF"

class="parental_control_off"><img src="https://' + current_jid + '/' +

this.approot + this.iconrc + '" /></div>');

$('#tab_parental_apps').show();

if(this.restricted === "0") {

document.getElementById(this.symbolicname + '_OFF').style.display = "block";

WORKS!

$('#'+this.symbolicname + '_OFF').css("display", "block"); DOESN"T WORK,

NEITHER DOES show();

document.getElementById(this.symbolicname + '_ON').style.display = "none";

$('#'+this.symbolicname + '_ON').css("display", "none");

} else {

document.getElementById(this.symbolicname + '_ON').style.display = "block";

$('#'+this.symbolicname + '_ON').css("display", "block");

document.getElementById(this.symbolicname + '_OFF').style.display = "none";

$('#'+this.symbolicname + '_OFF').css("display", "none");

}

Attachments (0)
Change History (2)

Changed November 07, 2013 12:54AM UTC by epascarello comment:1

So you are saying that you have an element with an id that has peroids

<div id="a.b.c.d.e">foo</div>

and you want to reference the element by its id. This is not a bug, you need to escape the periods as the docs state

console.log($("#a\\\\.b\\\\.c\\\\.d\\\\.e").html());

If you do not escape the periods, you are looking for an element with the id of a and with classes b, c, d, and e.

Changed November 07, 2013 01:03AM UTC by dmethvin comment:2

resolution: → notabug
status: newclosed

Right. For pathological ID names, the first choice would be to use non-pathological ID names. If this sane step cannot be taken, the easiest way to select them is $(document.getElementById("I.am.a.pathological.id")).