Solved

search for src filename using jQuery

Posted on 2014-01-30
6
313 Views
Last Modified: 2016-03-24
Hi,

I have this bit of code and I need to dynamically change some CSS on a paypal button. How do I search for the source filename in this part:

<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_installment_plan_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">

Open in new window


So I'm looking for the input type='image' where src='https://www.paypalobjects.com/en_US/i/btn/btn_installment_plan_LG.gif'

Thank you!
0
Comment
Question by:Victor Kimura
  • 3
  • 3
6 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39821373
This would get the object, what you do with it then is upto you
$("input[src='https://www.paypalobjects.com/en_US/i/btn/btn_installment_plan_LG.gif']")
0
 

Author Comment

by:Victor Kimura
ID: 39821374
I tried this:

var inputTypes = [];

                $('p#encypted_ppbtn input').each(function(){

                    var sCurSrcVal= $(this).attr(src);

                    if ( sCurSrcVal == "https://www.paypalobjects.com/en_US/i/btn/btn_installment_plan_LG.gif" ) {

                        $(this).css({"border": "0"});

                    }
                    inputTypes.push($(this).attr('type'));

                });

Open in new window


But it's failing at:
 var sCurSrcVal= $(this).attr(src);

How come?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39821380
Think you missed my comment above. Here's an example to change the src
http://jsfiddle.net/GaryC123/6v5uS/1/
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:Victor Kimura
ID: 39821388
Oh, I forgot the quotes:

var sCurSrcVal= $(this).attr('src');

=)
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39821398
If all you want to do is remove the border on the paypal button then just use

$("input[src='https://www.paypalobjects.com/en_US/i/btn/btn_installment_plan_LG.gif']").css({"border": "0"});
0
 

Author Comment

by:Victor Kimura
ID: 39821635
oh, that's much easier. Thanks, Cathal! =)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now