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="http://i1.ytimg.com/vi/LL0Y4MZ45bo/0.jpg" class="youtubeimg"></img>
<iframe src="" class="youtubeiframe"></iframe>

<script>
    $(function (){
        var youtubeid = $(".youtubeimg").attr("src").match(/[\w\-]{11,}/)[0];
        $(".youtubeiframe").attr({ 
              src: "http://www.youtube.com/embed/" + youtubeid,
        });
    });
</script>

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="i1.ytimg.com/vi/LL0Y4MZ45bo/0.jpg 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="http://www.youtube.com/embed/' + 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');
alert($imgvisible.attr('id'))

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(R.id.imageviewTest);
    imgView.setImageBitmap(bitMapObj);
}

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");
   //etc
});
//suggested by the others (most efficient)
   var id = this.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(R.id.viewFlipper01)
[Line 51] vf.setDisplayedChild(vf.indexOfChild(findViewById(R.id.viewFlipper01)));

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

android
Rectangle 27 0

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    init();
}

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

    Bitmap bitmap = BitmapFactory.decodeStream(is);
    imageView.setImageBitmap(bitmap);

         // if you dont want bitmap  you can use drawable

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

}

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

android
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(ui.offset.top - offsetY);


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



    console.log(x);
    console.log(y);
    // get the drop payload (here the payload is the image)
    var element = ui.draggable;
    var data = element.data("url");
    var theImage = element.data("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(ui.offset.top - offsetY);

    global_image = image;
    //
    layer.add(image);
    layer.draw();
    $("#clear").click(function () {

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

    });

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


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

}

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:

element[0].id

or with jQuery:

$(element).attr('id')

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);
        image.parentNode.appendChild(a);
        a.appendChild(image);
    }
}

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(this.id)", example:

<script>
      function yourFunction(id) {
        alert(id);
      }
    </script>

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

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

function mouseOver(e){
   alert(e.id);
}

Edit from the comments

var image=document.createElement("img");
   image.className += " Atributes";
   image.src="images/foto_klein_"+i+".jpg";
   image.width="135";
   image.height="90";
   image.alt="foto_klein_"+i;
   image.id="image"+i;
   image.mouseover = mouseOver;
   image.position="relative";
   div.appendChild(image);
   image.style.marginRight = '10px';
   _img.push(image);

}

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( this.id );
        }
    }
};

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

        Response.Write(cellVal.ToString());

    }
}

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

c# asp.net 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.

https://www.googleapis.com/plus/v1/people/115950284...320?fields=image&key={YOUR_API_KEY}
{
    "image": 
    {
         "url": "https://lh3.googleusercontent.com/-OkM...AANA/ltpH4BFZ2as/photo.jpg?sz=50"
    }
}

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