Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Posted
Comments
Sergey Alexandrovich Kryukov 30-Sep-14 3:16am    
What image? It could be a background image, or a part of inner HTML of th.

What is "category tag"?
1) there is no such tag, 2) you did not show any tag with such names.
In all cases, I see no problem.

Don't mist up HTML notions 1) tag, 2) element, 3) attribute 4) attribute value, 5) text node.

—SA
Torakami 30-Sep-14 4:52am    
function StatusSorting(event) {

$("#<%= hdnSortingCategoryName.ClientID %>").val('Status');

var columnName = $("#<%= hdnColumnName.ClientID %>").val();

if (columnName != 'Status') {
$("#<%= hdnSortOrder.ClientID %>").val('');
$("#<%= hdnColumnName.ClientID %>").val('Status');
}

var ordervalue = $("#<%= hdnSortOrder.ClientID %>").val();
if (ordervalue == "") {
debugger;
$(event).parent().append("<img id='theImg' src='../images/up_arrow.png'/>");
$("#<%= hdnSortOrder.ClientID %>").val('asec');
$("#<%= btnSorting.ClientID %>").click();
}
else if (ordervalue == 'asec') {
$("#<%= hdnSortOrder.ClientID %>").val('desc');
$("#<%= btnSorting.ClientID %>").click();
$(event).parent().append("<img id='theImg' src='../images/down_arrow.png'/>");
}
else if (ordervalue == 'desc') {
$("#<%= hdnSortOrder.ClientID %>").val('asec');
$("#<%= btnSorting.ClientID %>").click();
$(event).parent().append("<img id='theImg' src='../images/up_arrow.png'/>");
}
}

I tried this , but refresh is happening i am loosing the image ..I also tried to add after click even which is happening on server side .. but still refrsh happens and loosing the image

Add a class to 'a' tag

<table><thead><th class="reportgridheader">
<a href="#" class="category">Category</a>
</th></thead></table>




Add JQuery code

$(document).ready(function () {
    $('.category').click(function() {
        $(this).parent().append( "<img src='' />" );
    });
});


If you are looking for background image of parent element, use this code

$(document).ready(function () {
    $('.category').click(function() {
         $(this).parent().css("background-image", "pathOfTheImage");
    });
});
 
Share this answer
 
v2
Comments
Torakami 30-Sep-14 3:48am    
function StatusSorting(event) {

$("#<%= hdnSortingCategoryName.ClientID %>").val('Status');

var columnName = $("#<%= hdnColumnName.ClientID %>").val();

if (columnName != 'Status') {
$("#<%= hdnSortOrder.ClientID %>").val('');
$("#<%= hdnColumnName.ClientID %>").val('Status');
}

var ordervalue = $("#<%= hdnSortOrder.ClientID %>").val();
if (ordervalue == "") {
debugger;
$(event).parent().append("<img id='theImg' src='../images/up_arrow.png'/>");
$("#<%= hdnSortOrder.ClientID %>").val('asec');
$("#<%= btnSorting.ClientID %>").click();
}
else if (ordervalue == 'asec') {
$("#<%= hdnSortOrder.ClientID %>").val('desc');
$("#<%= btnSorting.ClientID %>").click();
$(event).parent().append("<img id='theImg' src='../images/down_arrow.png'/>");
}
else if (ordervalue == 'desc') {
$("#<%= hdnSortOrder.ClientID %>").val('asec');
$("#<%= btnSorting.ClientID %>").click();
$(event).parent().append("<img id='theImg' src='../images/up_arrow.png'/>");
}
}

I tried this , but refresh is happening i am loosing the image ..I also tried to add after click even which is happening on server side .. but still refrsh happens and loosing the image
Shemeemsha (ഷെമീംഷ) 30-Sep-14 6:25am    
Put # as href value...Like
--------------------
a href='#'
-------------------

If you forgot to add the #, the page will refresh...
Torakami 30-Sep-14 6:31am    
I alrready have #
Shemeemsha (ഷെമീംഷ) 30-Sep-14 6:43am    
oh...Then try using
a href="javascript:void(0);"
Torakami 30-Sep-14 6:46am    
let me check ..
Please see my comment to the question. In all cases, all you need is this:
http://api.jquery.com/attr[^] (to modify attribute value, like in <image src="..."/>),
http://api.jquery.com/category/manipulation[^] (for DOM insertion of any inner HTML you may need),
http://api.jquery.com/category/css[^] (to change the element's class using properties like background-image).

You choose what you need to use.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900