Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alex-boom/819f38975724e7b02544b92faf826158 to your computer and use it in GitHub Desktop.
Save alex-boom/819f38975724e7b02544b92faf826158 to your computer and use it in GitHub Desktop.
do one line content for atributes title and alt
//Разбивает текст тайтла на два тега, оставляя в тайтле начало строки до найденного маяка /alt/ и забирает текст
//от маяка /alt/ в тег alt.
var $this = $(".portfolio-detail-inner a");
$.each( $this, function () {
var str = $(this).attr("title");
var search = str.search(/alt/);
var gettingStr = function() {
if (search > 0 ) {
var from = search;
var to = str.length;
var $newstr = str.substring(from,to);
return $newstr;
} else {
console.log('');
}
};
var textAlt = function() {
var from = 4;
var to = gettingStr().length;
var newstr = gettingStr().substring(from,to);
return newstr;
};
var textTitle = function() {
if (search > 0 ) {
var from = search;
var to = 0;
var $newstr = str.substring(from,to);
return $newstr;
} else {
console.log('');
}
};
$(this).attr("title", textTitle);
$(this).find("img").attr("alt", textAlt);
$(this).find("span").text("");
//do one line content for atributes title and alt
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment