- Attended a Community Meetup
- Author was Featured
- Beta Tester
- Bought between 10 and 49 items
- Contributed a Tutorial to a Tuts+ Site
- Exclusive Author
- Has been a member for 3-4 years
- Interviewed on the Envato Notes blog
Here is my code:
$jadmin("#page_template_select select").change(function () {
var selected_meta_box = '#' + (($jadmin(this).find("option:selected").attr("role")).replace(/ /g, "_")).toLowerCase();
$jadmin("#page_template_select select option").each(function () {
if ($jadmin(this).text() != "Default") {
var meta_box = $jadmin(this).attr("role").replace(/ /g, "_").toLowerCase();
$jadmin('div#' + meta_box).hide();
}
});
$jadmin(selected_meta_box).show();
});
Why do I get this error?
Uncaught syntax error, unrecognised expression: #
I don’t get how it can call a string an expression.
Been trying to diagnose for 2 hours and I can’t find a solution, please help!
- Microlancer Beta Tester
- Author had a Free File of the Month
- Has been a member for 3-4 years
- Item was Featured
- Author was Featured
- Austria
- Exclusive Author
- Referred between 200 and 499 users
$jadmin("#page_template_select select").change(function () {
var selected_meta_box = (($jadmin(this).find("option:selected").attr("role")).replace(/ /g, "_")).toLowerCase();
$jadmin("#page_template_select select option").each(function () {
if ($jadmin(this).text() != "Default") {
var meta_box = $jadmin(this).attr("role").replace(/ /g, "_").toLowerCase();
$jadmin('div#' + meta_box).hide();
}
});
$jadmin('#' + selected_meta_box).show();
});
- Attended a Community Meetup
- Author was Featured
- Beta Tester
- Bought between 10 and 49 items
- Contributed a Tutorial to a Tuts+ Site
- Exclusive Author
- Has been a member for 3-4 years
- Interviewed on the Envato Notes blog
Didn’t work 
It only works without the each function like this:
$jadmin("#page_template_select select").change(function () {
var selected_meta_box = (($jadmin(this).find("option:selected").attr("role")).replace(/ /g, "_")).toLowerCase();
$jadmin('#' + selected_meta_box).show();
});
So its something wrong with that.
- Author had a Free File of the Month
- Author was Featured
- Bought between 10 and 49 items
- Egypt
- Exclusive Author
- Has been a member for 2-3 years
- Item was Featured
- Referred between 10 and 49 users
- Sold between 10 000 and 50 000 dollars
on which line does that error appear? http://cl.ly/7jZ6 or http://cl.ly/7hyV
- Sold between 250 000 and 1 000 000 dollars
- Community Moderator
- Author was Featured
- Item was Featured
- Bought between 50 and 99 items
- Referred between 1000 and 1999 users
- Has been a member for 3-4 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
Weird, your code seems to work in this fiddle: http://jsfiddle.net/sevenspark/8pYUy/1/
- Attended a Community Meetup
- Author was Featured
- Beta Tester
- Bought between 10 and 49 items
- Contributed a Tutorial to a Tuts+ Site
- Exclusive Author
- Has been a member for 3-4 years
- Interviewed on the Envato Notes blog
Yesss! I fixed it. There was somehow an extra interation in the each loop. So when jquery tried to hide it, it didnt exist so threw an error. Weird though as this never usually happens, its like my code was haunted by an AS3 compiler.
