javascript - jQuery & Bootstrap - Replacing a set of classes with button -
i working on making web-based storyboard video build on twitter bootstrap. consists of container 12 images (4 across 3 down) , chunk of text below each image (for different sections of video's script).
to populate script boxes, using jquery's .text method, , images static links. because storyboard have more 12 frames, want show many on-screen @ time, added button @ bottom of page link next page. planning have button hide first 12 frames, , replace them new set. however, can't seem make work.
i added .set01 class of first 12 frames, , next button hides .set01
html
<div class="row"> <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3"> <img src="frames/1.png" class="img-responsive" data-toggle="modal" data-target="#modal1" /> </div> <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3"> <img src="frames/2.png" class="img-responsive" data-toggle="modal" data-target="#modal1" /> </div> <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3"> <img src="frames/3.png" class="img-responsive" data-toggle="modal" data-target="#modal1" /> </div> <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3"> <img src="frames/4.png" class="img-responsive" data-toggle="modal" data-target="#modal1" /> </div> </div> <div class="row"> <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3"> <div class="scriptbox set01 frame01">lorem ipsum dolor sit amet, consectetur adipisicing elit</div> </div> <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3"> <div class="scriptbox set01 frame02">sed eiusmod tempor incididunt ut labore et dolore magna aliqua</div> </div> <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3"> <div class="scriptbox set01 frame03"> ut enim ad minim veniam, quis nostrud exercitation ullamco laboris</div> </div> <div class="col-xs-12 col-sm-6 col-md-3 col-lg-3"> <div class="scriptbox set01 frame04">nisi ut aliquip ex ea commodo consequat</div> </div> </div> <input type="button" class="btn btn-warning btn-large nextbutton" value="next page"/>
js
var populate1 = function(){ $(".frame01").text("it worked!"); $(".frame02").text("it worked!"); $(".frame03").text("it worked!"); $(".frame04").text("it worked!"); } $(document).ready(populate1); $("nextbutton").click(function{ $(".set01").hide(); });
the populate1 function works fine, when add in button's function breaks it, if don't click on button. i'm stumped!
thanks in advance help!
there numerous things can done, starting wrapping in document.ready statement. resolve concerns, did not include "period" before "nextbutton" in click event - button. however, event being triggered because left out open , close parens between function , { in same statement. should be:
var populate1 = function(){ $(".frame01").text("it worked!"); $(".frame02").text("it worked!"); $(".frame03").text("it worked!"); $(".frame04").text("it worked!"); } $(document).ready(populate1); $(".nextbutton").click(function(){ $(".set01").hide(); });
Comments
Post a Comment