javascript - switch content class after click image link -
i want build similar concept of site https://www.marketingprofsu.com/course/list
with 2 image , when click on image compare specific content on bottom of image(fullwidth).this require responsive
how make ? markup similar this:
<div class="imagecontainer"></div> <div class="image1"></div> <div class="image2"></div> </div> <div class="contentcontainer"></div> <div class="content1"></div> <div class="content2"></div> </div>
update
i have tested evry code posted nver work in page not understand why,this page :
<?php if ( !defined( 'abspath' ) ) { exit; // exit if accessed directly } ?> <?php if ( have_posts() ) : ?> <div class="row archive-courses course-list archive_switch" itemscope itemtype="http://schema.org/itemlist"> <?php // start loop. while ( have_posts() ) : the_post(); learn_press_get_template( 'archive-course-content.php' ); endwhile; // previous/next page navigation. ?> </div> <?php learn_press_course_paging_nav(); endif; ?>
view mistake in every test.
look @ example.
$('li').click(function(){ $(this).parent().find('.selected').removeclass('selected'); $(this).addclass('selected'); $('.content').hide(); var content = $(this).attr('ref'); $('#'+ content).show(); });
ul { width: 100%; } ul li { width:100px; height: 100px; display: inline-block; border-radius: 100px; text-align: center; background-color: #ccc; line-height: 100px; vertical-align: middle; cursor: pointer; } ul li:hover, ul li.selected { background-color: #eee; } div.content { display: block; width: 300px; height: 100px; background-color: yellow; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <ul> <li ref="div-1" class="selected">button 1</li> <li ref="div-2">button 2</li> <ul> <div> <div id="div-1" class="content">div 1</div> <div id="div-2" class="content" style="display: none;">div 2</div> </div>
Comments
Post a Comment