0

I have some jquery which is used after a postback to the page on which i take a value that was set in a hidden field and find the div corresponding to that value. I then do some css class changes on the div and its contents. I have similar code for the click event of this but need this to work on page startup.

Here is my fiddle:

http://jsfiddle.net/amwz/vks4n5bo/

and the jquery I am using:

$(document).ready(function () {
var currPackage = $("#HF_Package").val();

$("#" + currPackage).closest('.radio-group-row').find('.package-title').removeClass('highlight');
$("#" + currPackage).closest('.radio-group-row').find('.package-footer').removeClass('highlight');
$("#" + currPackage).find('input:radio').prop('checked', true);
$("#" + currPackage).find('.package-title').addClass('highlight');
$("#" + currPackage).find('.package-footer').addClass('highlight');
});

EDIT___

Error: Syntax error, unrecognized expression: #E/CS/PSTN_P1

The console in the fiddle gives me this error, although my jquery is valid no?

user667430
  • 1,487
  • 8
  • 38
  • 73

2 Answers2

1

You have to replace your HTML element ids, they contain invalid characters.

To have a look which characters are allowed follow What are valid values for the id attribute in HTML?

Community
  • 1
  • 1
SBH
  • 1,787
  • 3
  • 22
  • 27
1

try this:-

 var currPackage = $("#HF_Package").val().replace(new RegExp("/",'g'),"\\/");

Demo

Umesh Sehta
  • 10,555
  • 5
  • 39
  • 68