И что дальше? Проверка if (target.tagName != 'TD') return; справляется со своей задчей - игнорирует все, кроме td.
target == 'strong'
$('table').on('click', 'td', function() {
//handler
});
var date = new Date();
var year = date.getFullYear();
var listGroup = $('.list-group');
for(var i = 0; i < 10; i++) {
var currentYear = year - i;
var a = $('<a href="' + currentYear + '" class="list-group-item">' + currentYear + '</a>');
listGroup.append(a);
}
router.get('/', routeCache.cacheSeconds(20), async (req, res) => {
const posts = await models.Post.getPostsList({ limit: 10 });
res.json(posts);
});
router.get('/', async (req, res) => {
const posts = await models.Post.getPostsList({ limit: 10 });
res.render('index', { posts_list: posts });
});
$('.wrapper').on('click', '.btn', function() {
//handler
});
$('.wrapper').on('click', function(e) {
if ($(e.target).hasClass('btn')) {
//handler
}
});
document.querySelector('.wrapper').addEventListener('click', function(e) {
if(e.target && e.target.classList.contains('btn')) {
//handler
}
});
const makeParams = params => ({
headers: {
Authorization: `Bearer ${cookies.get('frl_jwt_token')}`,
},
params: { ...params },
})
<div contenteditable="true"></div>
function (event) {
if (!event.shiftKey && event.which === 13) {
event.preventDefault();
// тут код для отправки сообщения
}
}
<div id="app">
<div class="wrapper">
<div class="text-box" contenteditable="true" v-on:keypress="handleKeypress($event)"></div>
</div>
</div>
new Vue({
el: '#app',
methods: {
handleKeypress: function(e) {
if (!e.shiftKey && e.which === 13) {
e.preventDefault();
}
}
},
})
'use strict';
var _POS = {};
(function () {
navigator.geolocation.getCurrentPosition(function (position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
_POS.lat = lat;
_POS.lng = lng;
});
}()); // <== тут добавлен вызов функции
(function () {
navigator.geolocation.getCurrentPosition(function (position) {
/*
* инициализировать модули и функции использующие
* данные подученные от навигатора надо тут
*
*/
});
}());
var auto = [
{
marka: "BMW",
model: "4k",
cuzov: "A",
},
{
marka: "Merc",
model: "4k",
cuzov: "B",
},
{
marka: "Audi",
model: "3k",
cuzov: "C",
},
{
marka: "Toyota",
model: "1k",
cuzov: "D",
},
{
marka: "Lexus",
model: "2k",
cuzov: "E",
},
{
marka: "Rang",
model: "3k",
cuzov: "F",
},
{
marka: "BMW",
model: "4k",
cuzov: "G",
},
{
marka: "BMW",
model: "2k",
cuzov: "Y",
},
{
marka: "Audi",
model: "3k",
cuzov: "U",
}
];
var marka = ["Audi", "Rang", "Merc"];
var model = ["4k", "2k", "3k"];
var cuzov = [];
var params = { marka, model, cuzov };
var activeKeys = Object.keys(params).filter(key => params[key].length);
var rez1 = auto.filter(x => activeKeys.every(key => params[key].includes(x[key])) );
console.log(rez1);
class ActionsReducers extends React.Component {
handleAddMan = () => {
this.props.addMan({ name: 'Альберт', family: 'Эйнштейн' });
};
render() {
const { men } = this.props;
return (
<Wrapper>
<List>
{men.map(man => <Man key={man.id} man={man} />)}
{!men.length && <Empty>No data in list.</Empty>}
</List>
<Button onClick={this.handleAddMan}>Add man</Button>
</Wrapper>
);
}
}
class ActionsReducers extends React.Component {
componentDidMount() {
this.props.addMan({ name: 'Альберт', family: 'Эйнштейн' });
}
render() {
const { men } = this.props;
return (
<Wrapper>
<List>
{men.map(man => <Man key={man.id} man={man} />)}
{!men.length && <Empty>No data in list.</Empty>}
</List>
</Wrapper>
);
}
}
const mapStateToProps = state => ({
userData: state.userData,
});
import { createSelector } from 'reselect';
export const userDataSeleror = state => state.userData;
export const userSelector = state => createSelector(
userDataSelector,
userData => userData.user,
);
export const isUserDataLoadingSelector = state => createSelector(
userDataSelector,
userData => userData.isLoading,
);
export const isUserDataErrorSelector = state => createSelector(
userDataSelector,
userData => userData.isError,
);
import { fetchUserData } from './somePlace';
import Profile from './Profile';
import {
userSelector,
isUserDataLoadingSelector,
isUserDataErrorSelector,
} from './selectors';
const mapStateToProps = state => ({
user: userSelector(state),
isLoading: isUserDataLoadingSelector(state),
isError: isUserDataErrorSelector(state),
});
const mapDispatchToProps = {
fetchUserData,
};
export default connect(mapStateToProps, mapDispatchToProps)(Profile);
class Profile extends Component {
componentDidMount() {
this.props.fetchUserData();
}
render() {
const { user, isLoading, isError } = this.props;
return (
...
);
}
}