Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to replace src content in image control in jquery?

Posted on 2014-09-24
3
154 Views
Last Modified: 2014-09-27
Hi,
I have this jquery code below that works fine with the label web control. What it basically does is to find the webcontrol with the specific id and eval the data from xml table.

Works fine
=================
$(".filename", table).html(customer.find("filename").text());

<asp:Label ID="lblFilename" class="filename" runat="server" Text='<%# Eval("filename")%>'></asp:Label>



Now what if i want to use the same application on a image control? The below doesn't work

Not working
==============
$(".imgPhoto", table).html(customer.find("filename").text());

<img class="imgPhoto" src='<%# Eval("filename")%>' />

Any help is greatly appreciated.
0
Comment
Question by:tangteng78
3 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 250 total points
ID: 40342044
If you want to change the img src

$(".imgPhoto", table).attr("src","newsource.jpg")
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 40342124
try this :

jQuery(function($) { // be sure to wait complete page loading of the page, similar to window.onload or $(document).ready(function() {
     var filename = $("<%= lblFilename.ClientID %>").text();
     $("table .imgPhoto").attr("src", filename);
});

Open in new window

0
 

Author Closing Comment

by:tangteng78
ID: 40347469
Bulls eye
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
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…

839 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