JavaScript
13
Вклад в тег
let breadcrumbs = [`site.com/catalog`, `site.com/catalog/sub-catalog`, `site.com/catalog/sub-catalog/item`];
let indexCurrent = breadcrumbs.indexOf(location.href);
let indexPrev = Math.max(0, indexCurrent - 1);
let prevURL = breadcrumbs[indexPrev];
location.href = prevURL;
mySuperFunction1(ignoreCache, isReverse, removeEmpty, visible) { ... }
mySuperFunction2({ignoreCache, isReverse, removeEmpty, visible}) { ... }
mySuperFunction1(false, true, true, true);
mySuperFunction2({
ignoreCache: false,
isReverse: true,
removeEmpty: true,
visible: true
})
$emit(`name`, [arg1, arg2]);
@событие="metod(...$event)"
document.querySelector(".mainslider_slider").scrollLeft = 0;
<button id="but1">Кнопка 1</button>
<button id="but2">Кнопка 2</button>
<button id="but3">Кнопка 3</button>
<br>
<br>
<img width="300" src="http://dreempics.com/img/picture/Jun/04/08837d979a3d1531294922001a35e406/2.jpg" alt="" id="setImg">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
(function($){
$.fn.updateImg = function(conf){
var defConf = {
elem_img : null,
url_img : null,
}
$.extend(defConf, conf);
if( defConf.elem_img != null && defConf.url_img != null ) {
$( this ).click(function() {
$( defConf.elem_img ).attr( "src", defConf.url_img );
});
}
}
})(jQuery);
$(document).ready(function() {
$("#but1").updateImg({
elem_img : "#setImg",
url_img : "http://oxy.org.ua/wp-content/uploads/2009/08/d185d0b8.jpg"
});
$("#but2").updateImg({
elem_img : "#setImg",
url_img : "http://img0.joyreactor.cc/pics/post/full/Nyan-Cat-%D0%BE%D0%B1%D0%BE%D0%B8-%D0%BA%D1%80%D0%B0%D1%81%D0%B8%D0%B2%D1%8B%D0%B5-%D0%BA%D0%B0%D1%80%D1%82%D0%B8%D0%BD%D0%BA%D0%B8-art-851091.jpeg"
});
$("#but3").updateImg({
elem_img : "#setImg",
url_img : "http://www.yakako.ru/uploads/posts/2010-07/1277990808_kartinki-plamya-ognia-01.jpg"
});
});