Results 1 to 6 of 6
Hybrid View
-
23rd June 2010 19:54 #1
Javascript or Jquery event handler
:
, .Code:function show_project_details(service_id, project_id,object) { $('#secondGallery_'+project_id+' ul li img').each(function() { $(this).css('border','none'); }); object.setAttribute('style', "border:3px solid #000"); //Another code object.setAttribute('onmouseup', "close_project_details("+service_id+", "+project_id+", this);"); function close_project_details(service_id, project_id, object) { object.setAttribute('onmouseup', "show_project_details("+service_id+", "+project_id+", this);"); object.setAttribute('style', "border: none"); }
// :
$(this).attr('onmouseup','function');
.:Code:$('#secondGallery_'+project_id+' ul li img').each(function() { // . $(this).css('border','none'); // . $(this).attr('onmouseup','"show_project_details("+service_id+", "+project_id+", this);");') });
:
-show_projects_details - ajax .
-close_project_details - .
:
show_projects_detail close_project_detail show_projects_detail.
:
close_project_details , , close_project_details show_projects_details.
:
$(this).attr('onmouseup','"show_project_ details("+service_id+", "+project_id+", this);");')
, .
-
23rd June 2010 20:52 #2
-
23rd June 2010 21:12 #3
( ) event-handlers .attr() . .bind() .mouseup() .
, !
-
24th June 2010 00:16 #4
.
html Kod :
<img onmouseup="show_project_details(1, 1,this);"/>
<img onmouseup="show_project_details(1, 2,this);"/>
<img onmouseup="show_project_details(1, 3,this);"/>
img[0] html :
<img onmouseup="close_project_details(1, 1,this);"/>
<img onmouseup="show_project_details(1, 2,this);"/>
<img onmouseup="show_project_details(1, 3,this);"/>
img[1] html :
<img onmouseup="close_project_details(1, 1,this);"/>
<img onmouseup="close_project_details(1, 2,this);"/>
<img onmouseup="show_project_details(1, 3,this);"/>
am img[0] close_project_details , show_project_details(argument 1,argument 2,this)
, .Last edited by bombov; 24th June 2010 at 00:25.
-
24th June 2010 00:28 #5Registered User
Join Date: Feb:2006
Location: Plovdiv
Posts: 392
:
Code:<img onmouseup="change_project_details_state(1, 1,this);" data-state="open_close" />
-
24th June 2010 02:04 #6
- unbind live.
, test.html :
test.js:HTML Code:<html> <body> <img src="http://www.w3schools.com/images/compatible_ie.gif" id="img0"/><br> <img src="http://www.w3schools.com/images/compatible_ie.gif" id="img1"/><br> <img src="http://www.w3schools.com/images/compatible_ie.gif" id="img2"/><br><br> Project 0 <span id="details0"></span><br> Project 1 <span id="details1"></span><br> Project 2 <span id="details2"></span> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script src="test.js"></script> </body> </html>
Code:$(function(){ $('img').click(function() { manageProjectDetails.call(this); }); function manageProjectDetails(hide){ id = this.id.match(/\d+/); span = $($('#details' + id)[0]);; if(hide) span.hide(); else span.show().text('AJAX call returned details for project ' + id); $(this).unbind('click').click(function() { manageProjectDetails.call(this, ! hide); }); } });




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in