What I'm trying to do is build a team page. Similar to http://www.razorfish.com/people/ourpeople.htm
I want to create a floated or inline row of elements, and show hidden content within each inline element UNDER the selected element. Thus, moving the next row further down.
However, I'm a newbie to JavaScript.
This is what I have now: jsfiddle
// var tag = $(this).parent().find(".hidden-info");
// var prevStyle = tag.attr('style');
$('.profile-header').click(function(){
//$('.hidden-info').show();
$(this).parent().find(".hidden-content").toggle();
//return false;
$(this).parent().find(".hidden-content").append(".people");
$(this).parent().find(".hidden-content").css("position","relative", "z-index","99");
});
Does anyone have any idea on how to go about achieving this?
Rather than traversing the DOM using .parent()
and .find()
, you can simply specify the selector context:
$('.profile-header').click(function(){
var $this = $(this),
hidden_content = $(".hidden-content", $this);
hidden_content.toggle().toggleClass("people");
});
Your append
as written won't do anything. If you are trying to change its class, you should consider using addClass
or toggleClass
instead and add your CSS to the new class rather than changing your CSS in the javascript.
Place a .people-data
div under each row of people. on each people click, find the .people-data
that corresponds to that row and populate it with data.
$('.profile-header').parent().find('.people-data') // populate and show
Edit:
If you want it to be responsive, place the .people-data
under each person and expand it the same way you would a row. This will work if you have each person item display:inline-block
The key changes are:
display: none;
instead of float: left;
to the li
's position: absolute;
and left: 0px;
to the .hidden-content
li
's height programatically to pull the next line down li
's to hide old detailing section
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.