Skip to main content
Code Review

Return to Answer

added 2 characters in body
Source Link
James Khoury
  • 3.2k
  • 1
  • 25
  • 51

if you add the parent div class into the data attributes:

<button id="egyes" class="btn btn-danger" data-parentclass="progress-danger">Hide</button>&nbsp;some text 
<button id="kettes" class="btn btn-warning" data-parentclass="progress-warning">Hide</button>&nbsp;other text
<button id="harmas" class="btn btn-info" data-parentclass="progress-info">Hide</button>&nbsp;some more text
<button id="otos" class="btn btn-success" data-parentclass="progress-success">Hide</button>&nbsp;last button
<button id="showall" class="btn">Show all</button>

or add it in via javascript:

$("#egyes").data("parentclass", progress"progress-dangerdanger");
// etc

then the javascript can work it out itself. ​

$(document).ready(function() {
 $("#egyes, #kettes, #harmas, #otos").click( function() {
 var $parent = $("div." $(this).data("parentclass")).parent();
 if ($parent.is(":visible")) {
 $(this).html("Hide");
 } else {
 $(this).html("Show");
 }
 parent.fadeToggle();
 });
 
 
 $("#showall").click( function() {
 $("div.container > div > div.progress").parent().fadeIn();
 });
 });

if you add the parent div class into the data attributes:

<button id="egyes" class="btn btn-danger" data-parentclass="progress-danger">Hide</button>&nbsp;some text 
<button id="kettes" class="btn btn-warning" data-parentclass="progress-warning">Hide</button>&nbsp;other text
<button id="harmas" class="btn btn-info" data-parentclass="progress-info">Hide</button>&nbsp;some more text
<button id="otos" class="btn btn-success" data-parentclass="progress-success">Hide</button>&nbsp;last button
<button id="showall" class="btn">Show all</button>

or add it in via javascript:

$("#egyes").data("parentclass", progress-danger);
// etc

then the javascript can work it out itself. ​

$(document).ready(function() {
 $("#egyes, #kettes, #harmas, #otos").click( function() {
 var $parent = $("div." $(this).data("parentclass")).parent();
 if ($parent.is(":visible")) {
 $(this).html("Hide");
 } else {
 $(this).html("Show");
 }
 parent.fadeToggle();
 });
 
 
 $("#showall").click( function() {
 $("div.container > div > div.progress").parent().fadeIn();
 });
 });

if you add the parent div class into the data attributes:

<button id="egyes" class="btn btn-danger" data-parentclass="progress-danger">Hide</button>&nbsp;some text 
<button id="kettes" class="btn btn-warning" data-parentclass="progress-warning">Hide</button>&nbsp;other text
<button id="harmas" class="btn btn-info" data-parentclass="progress-info">Hide</button>&nbsp;some more text
<button id="otos" class="btn btn-success" data-parentclass="progress-success">Hide</button>&nbsp;last button
<button id="showall" class="btn">Show all</button>

or add it in via javascript:

$("#egyes").data("parentclass", "progress-danger");
// etc

then the javascript can work it out itself. ​

$(document).ready(function() {
 $("#egyes, #kettes, #harmas, #otos").click( function() {
 var $parent = $("div." $(this).data("parentclass")).parent();
 if ($parent.is(":visible")) {
 $(this).html("Hide");
 } else {
 $(this).html("Show");
 }
 parent.fadeToggle();
 });
 
 
 $("#showall").click( function() {
 $("div.container > div > div.progress").parent().fadeIn();
 });
 });

deleted 13 characters in body
Source Link
James Khoury
  • 3.2k
  • 1
  • 25
  • 51

if you add the parent div class into the data attributes:

<button id="egyes" class="btn btn-danger" data-parentclass="progress-danger">Hide</button>&nbsp;some text 
<button id="kettes" class="btn btn-warning" data-parentclass="progress-warning">Hide</button>&nbsp;other text
<button id="harmas" class="btn btn-info" data-parentclass="progress-info">Hide</button>&nbsp;some more text
<button id="otos" class="btn btn-success" data-parentclass="progress-success">Hide</button>&nbsp;last button
<button id="showall" class="btn">Show all</button>

or add it in via javascript:

$("#egyes").data("parentclass", progress-danger);
// etc

then the javascript can work it out itself. ​

$(document).ready(function() {
 $("#egyes, #kettes, #harmas, #otos").click( function() {
 var $parent = $("div." $(this).data("parentclass")).parent()
 .fadeToggle();
 if ($parent.is(":visible")) {
 $(this).html("Hide");
 } else {
 $(this).html("Show");
 }
 parent.fadeToggle();
 });
 
 
 $("#showall").click( function() {
 $("div.container > div > div.progress").parent().fadeIn();
 });
 });

if you add the parent div class into the data attributes:

<button id="egyes" class="btn btn-danger" data-parentclass="progress-danger">Hide</button>&nbsp;some text 
<button id="kettes" class="btn btn-warning" data-parentclass="progress-warning">Hide</button>&nbsp;other text
<button id="harmas" class="btn btn-info" data-parentclass="progress-info">Hide</button>&nbsp;some more text
<button id="otos" class="btn btn-success" data-parentclass="progress-success">Hide</button>&nbsp;last button
<button id="showall" class="btn">Show all</button>

or add it in via javascript:

$("#egyes").data("parentclass", progress-danger);
// etc

then the javascript can work it out itself. ​

$(document).ready(function() {
 $("#egyes, #kettes, #harmas, #otos").click( function() {
 var $parent = $("div." $(this).data("parentclass")).parent()
 .fadeToggle();
 if ($parent.is(":visible")) {
 $(this).html("Hide");
 } else {
 $(this).html("Show");
 }
 });
 
 
 $("#showall").click( function() {
 $("div.container > div > div.progress").parent().fadeIn();
 });
 });

if you add the parent div class into the data attributes:

<button id="egyes" class="btn btn-danger" data-parentclass="progress-danger">Hide</button>&nbsp;some text 
<button id="kettes" class="btn btn-warning" data-parentclass="progress-warning">Hide</button>&nbsp;other text
<button id="harmas" class="btn btn-info" data-parentclass="progress-info">Hide</button>&nbsp;some more text
<button id="otos" class="btn btn-success" data-parentclass="progress-success">Hide</button>&nbsp;last button
<button id="showall" class="btn">Show all</button>

or add it in via javascript:

$("#egyes").data("parentclass", progress-danger);
// etc

then the javascript can work it out itself. ​

$(document).ready(function() {
 $("#egyes, #kettes, #harmas, #otos").click( function() {
 var $parent = $("div." $(this).data("parentclass")).parent();
 if ($parent.is(":visible")) {
 $(this).html("Hide");
 } else {
 $(this).html("Show");
 }
 parent.fadeToggle();
 });
 
 
 $("#showall").click( function() {
 $("div.container > div > div.progress").parent().fadeIn();
 });
 });

Source Link
James Khoury
  • 3.2k
  • 1
  • 25
  • 51

if you add the parent div class into the data attributes:

<button id="egyes" class="btn btn-danger" data-parentclass="progress-danger">Hide</button>&nbsp;some text 
<button id="kettes" class="btn btn-warning" data-parentclass="progress-warning">Hide</button>&nbsp;other text
<button id="harmas" class="btn btn-info" data-parentclass="progress-info">Hide</button>&nbsp;some more text
<button id="otos" class="btn btn-success" data-parentclass="progress-success">Hide</button>&nbsp;last button
<button id="showall" class="btn">Show all</button>

or add it in via javascript:

$("#egyes").data("parentclass", progress-danger);
// etc

then the javascript can work it out itself. ​

$(document).ready(function() {
 $("#egyes, #kettes, #harmas, #otos").click( function() {
 var $parent = $("div." $(this).data("parentclass"))
 .parent()
 .fadeToggle();
 if ($parent.is(":visible")) {
 $(this).html("Hide");
 } else {
 $(this).html("Show");
 }
 });
 
 
 $("#showall").click( function() {
 $("div.container > div > div.progress").parent().fadeIn();
 });
 });

default

AltStyle によって変換されたページ (->オリジナル) /