views:

38

answers:

2

Well , i have tried Split("?") and Split('?')

both give the same error ( link.split is not a function) , so i assume that there is a way to be able to split in jetpack but not using this Split ? maybe jQuery ? hope someone can help in this issue.

Got it , it is a href Split , so yeah as jordan said , it was not a string . so i used x.href.split("?") worked like a charm

Thanks

+1  A: 

Jetpack just uses JavaScript so this should work:

var str = "My.string";
str.split("."); // => [ "My", "string" ]

If it tells you "split is not a function" then it probably means your variable doesn't hold a string like you think it does.

Jordan
Alright , Thanks alot .My value actually is a href var link= doc.querySelector('#courses_menu > ul > li:nth-child(2) a');Then i try to split it by "?"anyhelp ?
msheshtawy
Okay, that's useful, then. doc.querySelector() returns an element object: https://developer.mozilla.org/en/DOM/element and it looks like the most reliable way to get an attribute (like 'href') would be element.getAttribute('href'). That should return your URL string that you can then split.
Jordan
A: 

If the object is not already a string, convert it first.

myObject.toString().split("?");
Sam
That would be a good idea . Thanks however i used links.href.split("?"); and worked allright
msheshtawy