Rectangle 27 3

First, you're not supposed to have multiple DOM elements with the same id value on one page. Second, you can pass the clicked element to you handler:

<input type='text' size='4' value='$PHPimageid'  onclick ='displayID(this);' />

Then, in you javascript:

function displayID(el)
    alert(  el.value  );


javascript - how to get image id on image click - Stack Overflow

javascript php html image
Rectangle 27 2

This extracts the YouTube ID using a Regular Expression, I made the assumption that it would be a minimum of eleven characters as the first YouTube Video ID has 11.

<img src="" class="youtubeimg"></img>
<iframe src="" class="youtubeiframe"></iframe>

    $(function (){
        var youtubeid = $(".youtubeimg").attr("src").match(/[\w\-]{11,}/)[0];
              src: "" + youtubeid,

This works, however the YouTube Player API may provide you with a more stable solution to loading that iFrame, in the future once it becomes stable I would recommend the YouTube iFrame API

@user1010031 Yeah, absolutely. You mind marking it as answered?

i have one more query. is there something to say if <img src=" class="youtubeimg"></img> or the class .youtubeimg is not present on the page do not display .youtubeiframe the class for the iframe?

$(function (){     	if($(".youtubeimg").length){         	var youtubeid = $(".youtubeimg").attr("src").match(/[\w\-]{11,}/)[0];         	$(".youtubeimg").after('<iframe src="' + youtubeid +'" class="youtubeiframe"></iframe>');         }     });

jquery - how to get YouTube video id from image thumbnail source, and ...

jquery iframe youtube src
Rectangle 27 1

You can use the :visible selector to get the visible image

var $imgvisible = $('.slider img:visible');

But when the page loads it won't return anything because there are no visible images

Thank you so much, that was exactly what i was looking for.

javascript - Jquery get the image element ID from a group of images in...

javascript jquery html css image
Rectangle 27 0

It's because you are importing the svg from a file. If you include the svg markup on your page your code will work.

I think this is because when you import it the svg markup isn't loaded on the page yet so it cannot attach events to the path elements.

I did find a answer on StackOverflow that does address this. What you have to do is attach a load event to the object that when fired will attached your click events once it has been loaded.

jquery - On click svg image path get path id? - Stack Overflow

jquery svg snap.svg
Rectangle 27 0

File fileObj = new  File(/sdcard/Images/test_image.jpg);
if(fileObj .exists()){
    Bitmap bitMapObj= BitmapFactory.decodeFile(fileObj .getAbsolutePath());
    ImageView imgView= (ImageView) findViewById(;

but where are you finding resourceID of the image in it ?

You do not need resource id to decode a file. You need resource id, only if this particular image is in your resource folder. But you mentioned that the image is available on the sd card. You will not get a resource id for anything, which is not there in your apk.

android - How to get resource ID from Image Path? - Stack Overflow

android imageview
Rectangle 27 0

$(img).load(function() {
   var id = $(this).attr("id");
//suggested by the others (most efficient)
   var id =;

   //or if you want to keep using the object
   var $img = $(this);
   var id = $img.attr("id")

Thanks to all. I think you all are correct. I tried all answers and all worked. Thanks to all of you.

javascript - How to get image id using jQuery? - Stack Overflow

javascript jquery image attributes onload
Rectangle 27 0

You need to go and start studying the basics and doing the tutorials yourself.

Let me explain what Lines 50 & 51 in the code you just linked here does:

[Line 50] vf=(ViewFlipper)findViewById(
[Line 51] vf.setDisplayedChild(vf.indexOfChild(findViewById(;

What line 51 says is "Set my child view to the index of my child view that is actually myself". If that line doesn't make sense in English, it makes even less sense in Java where a view cannot contain itself as a child view

android - how to get image id of current flipper View and to set that ...

android viewflipper
Rectangle 27 0

You have to put your images in drawable folder to access them. Then you can use this code to get the id of images from their name..

String yourImageName;
 int resID = getResources().getIdentifier(yourImageName, "drawable", "com.example.yourpackegename.");

How to get asset images id in android - Stack Overflow

Rectangle 27 0

if you are keeping your image in assets than you have to decode it using asset manager .

protected void onCreate(Bundle savedInstanceState) {

private void init() {
    InputStream is = null;
    ImageView imageView = new ImageView(this);
    try {
     is = getAssets().open("ic_launcher.png");//name of image in your asset folder
    } catch (IOException e) {

    Bitmap bitmap = BitmapFactory.decodeStream(is);

         // if you dont want bitmap  you can use drawable

       // Drawable d = Drawable.createFromStream(is, null);


else keep your images in drawable folder in res and use it using R.drawable.imagename

How to get asset images id in android - Stack Overflow

Rectangle 27 0

Use ui.draggable.attr('id'); in your dragDrop function to get the id of the dragged image.

Simple solution for you to get the id of the dragged item.

var draggedElementID = ui.draggable.attr('id');

Here is the code where you can access it.

function dragDrop(e, ui) {
    var x = parseInt(ui.offset.left - offsetX);
    var y = parseInt( - offsetY);

    // Below line gives you the id of the image that is dragged.
    var draggedElementID = ui.draggable.attr('id');

    // get the drop payload (here the payload is the image)
    var element = ui.draggable;
    var data ="url");
    var theImage ="image");
    // create a new Kinetic.Image at the drop point
    // be sure to adjust for any border width (here border==1)
    var image = new Kinetic.Image({
        name: data,
        x: x,
        y: y,
        image: theImage,
        draggable: true
    var x = parseInt(ui.offset.left - offsetX);
    var y = parseInt( - offsetY);

    global_image = image;
    $("#clear").click(function () {

    document.getElementById('clear').addEventListener('click', function () {


    var x = parseInt(ui.offset.left - offsetX);
    var y = parseInt( - offsetY);

    window.tablePositionList[tableIndex] = [x, y];


javascript - How to get Id of image in canvas - Stack Overflow

javascript jquery html5 html5-canvas
Rectangle 27 0

In your dragDrop function, you have access to element variable which contains the element that is being dragged. You can access its ID attribute for example like this:


or with jQuery:


javascript - How to get Id of image in canvas - Stack Overflow

javascript jquery html5 html5-canvas
Rectangle 27 0

Note than in IE, the image.src value will be the full path of the image so you can't just prepend 'big/' to them.

Oops, didn't see that you were adding A elements. Presumably you want the images to be inside the link. Instead of innerHTML, you can use DOM methods to creat the links:

function addGallery(){

    var getDivId = document.getElementById("imgContainer");
    var path = '/images/galleries/';
    var images = toArray(getDivId.getElementsByTagName("img"));

    var oA = document.createElement('a');
    var a, image, parent;

    for(var i=0, iLen=images.length; i<iLen; i++) {
        image = images[i];
        a = oA.cloneNode(false);
        a.href = image.src.replace(path, '/big' + path);

function toArray(a) {
  var result = [];
  var i = a.length;
  while (i--) {
    result[i] = a[i];
  return result;

There is also a document.images collection that is all the images in the document, but likely you only want those in the div.

I'm not sure I get your answer (and attempting to not be a jerk about it)... He has to modify the DOM (or use a straight JS event), since he's attempting to add an anchor on top of the images that already exist. Really, this should be done server-side, but I think we can ignore that for now.

Sorry, missed the added links partanswer updated. Yes, should be a server-side thing but sometimes people have to try stuff client side before they get the point. :-)

Thank you for your help! I added now the link to each image, but I need to add a id and onclick event on each link, so I am stuck again... About the server-side solution, that would be great, if this wasn't a hosted CMS and no access to add php code. Anyway, if there is a better solution in PHP, whould you mind to expose that for us? Regards!

javascript - Get all images from a div ID and add links - Stack Overfl...

javascript innerhtml
Rectangle 27 0

add the function onclick="yourFunction(", example:

      function yourFunction(id) {

html - how to get the id of an img tag in php variable when an image i...

php html mysql css
Rectangle 27 0

Instead of making multiple elements, use the data-* attribute.

<a href="#" data-hover="url('image2.jpg')" style="background-image: url('image1.jpg');">&nbsp;</a>
$('a').hover( function() {
    var hoverImg = $(this).data('hover');
    var basicImg = $(this).css('background-image');
    $(this).data('hover', basicImg ).css('background-image', hoverImg );
a#imgId {
    background-image: url('image1.jpg');
a#imgId:hover {
    background-image: url('image2.jpg');

It looks as though the background images are coming dynamically from the server and the OP is looking to move them around on the client.

Ah, I guess your right, and I was looking at it too easy. I got another idea... let me work it out.

javascript - How to get the background image url of anchor tag using i...

javascript jquery html css
Rectangle 27 0

<div id="thumbnails" onmouseover="mouseOver(this);" ></div>

function mouseOver(e){

Edit from the comments

var image=document.createElement("img");
   image.className += " Atributes";
   image.mouseover = mouseOver;
   div.appendChild(image); = '10px';


Note the mouseOver function being called when the image is hovered. this will refer to the image element and not the div.

Yes thank you tried that already, but did not posted it. But the alert returns "thumbnails". And the images are nested inside the thumbnials. So how can i access them?

@user2072498 it returns thumbnails because that is the id.

@DarrenDavies he wants the id of <img> inside the said <div> I guess.

@DarrenDavies True, but I wasn't here when the question was asked and when you answered it. I came in late. I saw things didn't match. It's not up to me to go into the Edit histories of the question/answer and figure out how I should vote. Nonetheless, the point is that things change and you are welcome to accommodate (like just did with your edit), so I'd be happy to change my vote now because it seems right.

html - Javascript trying to get the ID of the image which the mouse mo...

javascript html css
Rectangle 27 0

Hope this helps, though I'm not sure about it working on a dynamically added image.

document.ready = function () {
    var thumbnails = document.getElementById("thumbnails");

    var imgs = thumbnails.getElementsByTagName("img");

    for( var i=0; i<imgs.length; i++ ) {
        imgs[i].onmouseover = function() {
            alert( );

html - Javascript trying to get the ID of the image which the mouse mo...

javascript html css
Rectangle 27 0

Here is a simple way:

protected void grdView_RowCommand(object sender, GridViewCommandEventArgs e)

    if (e.CommandName == "selectImage")

        int rowIndex = Convert.ToInt32(e.CommandArgument); // Get the current row
        int cellVal = Convert.ToInt32(grdView.Rows[rowIndex].Cells[2].Text);//Get the cell value



c# - How do i get id of the image from gridview and increase hits? - S...

c# sql gridview
Rectangle 27 0

Earlier I have also the same problem for my site after so much of research and efforts I found solution from my self and i hope that will also work for you and solve your problem:

Google had changed their policy so the old trick for getting the Google profile image will not work now.{YOUR_API_KEY}
         "url": ""

And While creating Public API access key you can choose Referers URL's from which this request should be made but for checking you should try by not adding any URL to it, if it works then go with URL of your site.

You can choose other fields to send with URL which you may need from here.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

web - How to get user image through user id in Google plus? - Stack Ov...

web google-api google-plus userinfo