1
votes

I have a JS _buildPlaylist file, and Isee this for example:

//create thumb
                thumb=$(new Image()).addClass('thumb_img').appendTo(div).attr('alt', _item.title?_item.title:'').css({
                   cursor:'pointer',
                   opacity:0
                }).load(function() {
                    $(this).stop().animate({ 'opacity':1}, {duration: 500, easing: 'easeOutSine'});//fade in thumb
                }).error(function(e) {

                }).attr('src', _item.thumbnail);

The line for crear image thumb with "alt title name"

This is the result:

 <img class="thumb_img" alt="Sample title builded here" style="cursor: pointer; opacity: 1;" src="http://mywebsite.com/image.jpg">

As you can see, this creates an image with an alt text attribute

Now, I want to change to build a < LI > List names

  • Sample title builded here (this is the ALT title name)

So, how can I change the image thumb to a text, or show alt title only?

2

2 Answers

0
votes

You dont need to use img tag if you dont want to display image. Just give it as a label or a link. That will do.

-1
votes

Rather than building off a new Image(), build off of an <a> wrapped in a <li>:

var thumb = $("<a>", { 
    'class': 'thumb_item', 
    'text' : (_item.title ? _item.title : "No title"),
    'href' : _item.thumbnail
}).wrap("<li>").parent().appendTo(div);​

Of course we would do away with the .load and .error handlers, since these events don't take place on list items.

Fiddle: http://jsfiddle.net/tudwA/