?
Solved

Append a url query parameter  all elements that have a css class of "appendServiceID"

Posted on 2009-04-20
1
Medium Priority
?
221 Views
Last Modified: 2012-05-06
Dear Experts,

I want to use JQuery to append a url query parameter to the "href" of each element that has the cssclass "appendServiceID". How can this be done?

I want something like this

for each element which has cssclass "appendServiceID"
   if this element has an "href"
      href.src = href.src + "&servideID=100"
0
Comment
Question by:vbhargav80
1 Comment
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 500 total points
ID: 24185301
use this
It also checks if the link contains a question mark
$("A.appendServiceID").each(function() {
    if(this.href != "") {
        if(this.href.indexOf("?") == "-1")
            this.href+= "?servideID=100";
        else
            this.href+= "&servideID=100";
    }
});

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question