Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

dom manipulation - Get the content of siblings elements with jQuery -


i need content of specific elements using jquery, problem have same element repeating on page:

<div class="content">    <img alt="" src="">    <p class="txt">lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>    <p class="info">lorem ipsum dolor...</p>    <ul>      <li><a class="uibutton">test</a></li>    </ul>  </div> 

so, div.content repeat on page many times , want contents of div holds button clicked. i've added onclick event on .uibutton , tried use parent(".txt") or siblings(".txt"), dont seems work...

$(".uibutton").click(function(){    var txt = $(this).parent(".txt").text();  } 

.txt isn't parent, , has direct parent (.parent() matches immediate parent if matches selector), instead need:

$(".uibutton").click(function(){    var txt = $(this).closest("ul").siblings(".txt").text();  }); 

the alternative go way .content (via .closest()) safe traverse down .find():

$(".uibutton").click(function(){    var txt = $(this).closest(".content").find(".txt").text();  }); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -