Hi all, help needed with simple jquery string filtering.... Thanks

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Hi all, help needed with simple jquery string filtering.... Thanks

ranger001
Hi, I'm new to the this whole scripting thing.  I'm having a little trouble with a function, i do not know how i would solve it. So any help would be awesome, I'm working on this one

<script type="text/javascript"> $(document).ready(function() { $('#stage_left li a').click(function() { var ListID = $(this).html(); $('#ClickedItem').removeClass().addClass(ListID); }); }); </script>
The li we are targeting have images in them, each image is inside an anchor and is referencing "#" So the images are clickable. every thing is working so far, but there a couple adjustments i need to make. here is a sample of the li markup

   <li></li>

now what i want to do is remove everything except any numbers in the target. so i would end up with "8" in this case. and then i want to append to the front "img_" so the final out come would be a class with the name "img_8".

I've looked into using the "split" statmenent in JS but to be honest I got totaly lost and could use some good examples on how to get this all done.  

Thanks,
Reply | Threaded
Open this post in threaded view
|

Re: Hi all, help needed with simple jquery string filtering.... Thanks

Ridima

ranger001 wrote
Hi, I'm new to the this whole scripting thing.  I'm having a little trouble with a function, i do not know how i would solve it. So any help would be awesome, I'm working on this one

<script type="text/javascript"> $(document).ready(function() { $('#stage_left li a').click(function() { var ListID = $(this).html(); $('#ClickedItem').removeClass().addClass(ListID); }); }); </script>
The li we are targeting have images in them, each image is inside an anchor and is referencing "#" So the images are clickable. every thing is working so far, but there a couple adjustments i need to make. here is a sample of the li markup

   <li></li>

now what i want to do is remove everything except any numbers in the target. so i would end up with "8" in this case. and then i want to append to the front "img_" so the final out come would be a class with the name "img_8".

I've looked into using the "split" statmenent in JS but to be honest I got totaly lost and could use some good examples on how to get this all done.  

Thanks,



This is really an interesting thread post which helps us to gain more knowledge by solving this problem. Thanks for posting.