console.log($(\'\"#\'+d+\'\"\'));
in html i have
5
eeeeeeeeeee
Try this (ES5)
console.log($("#" + d));
ES6
console.log($(`#${d}`));
console.log( $('#'+d) ); // single quotes only
console.log( $("#"+d) ); // double quotes only
Your selector results like this, which is overkill with the quotes:
$('"#abc"') // -> it'll try to find <div id='"#abc"'>
// In css, this would be the equivalent:
"#abc"{ /* Wrong */ } // instead of:
#abc{ /* Right */ }
This can also happen in safari if you try a selector with a missing ], for example
$('select[name="something"')
but interestingly, this same jquery selector with a missing bracket will work in chrome.
Try using:
console.log($("#"+d));
This will remove the extra quotes you were using.
I had to look a little more to solve my problem but what solved it was finding where the error was. Here It shows how to do that in Jquery's error dump.
In my case id
was empty and $("#" + id);
; produces the error.
It was where I wasn't looking so that helped pinpoint where it was so I could troubleshoot and fix it.
If you're using jQuery 2.1.4 or above, try this:
$("#" + this.d);
Or, you can define var before using it. It makes your code simpler.
var d = this.d
$("#" + d);