Created
June 16, 2016 06:27
-
-
Save Yago/f25c613b86a592cc519e677538ba7972 to your computer and use it in GitHub Desktop.
Classic website - JavaScript usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import $ from 'jquery'; | |
const format = () => { | |
$('.btn').each((i, e) => { | |
const that = $(e); | |
that.addClass('btn-danger'); | |
}); | |
}; | |
export default format; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<script src="//code.jquery.com/jquery-2.2.4.min.js" crossorigin="anonymous"></script> | |
<script src="/build/js/bundle.js"></script> | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import $ from 'jquery'; | |
import format from './format'; | |
import { toggleColor, toggleVisible } from './toggle'; | |
$(document).on('ready', () => { | |
format(); | |
toggleColor(); | |
toggleVisible(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import $ from 'jquery'; | |
export const toggleColor = () => { | |
if ($('#my-button').length > 0) { | |
$('#my-button').on('click', e => { | |
const that = $(e.currentTarget); | |
that.next().toggleClass('text-danger text-success'); | |
}); | |
} | |
}; | |
export const toggleVisible = () => { | |
if ($('#my-button').length > 0) { | |
$('#my-button').on('click', e => { | |
const that = $(e.currentTarget); | |
that.next().toggleClass('hidden'); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment