i have the lines of code below but seem not to be executed when called.
i made function to manage the hide and show jquery function when the elements are triggered by the click events - called showOptDivs and below i have included the function itself. the showOptDivs function executes without a problem at all the problem is the section when i included the function displayings, it seems not executing all … can someone help me know what could be the problem please? as it took me two hours an i could figure out… could it be the nesting of the jquery click events? but the rest of code work except that only? am confused… i am working this for a project. the reason i made the function is so i can simplify in case the structure of the divs are same but need to be replicated… so i thought instead of writing for each div elements i could simplify by using a function, but it is turning to a dead end… help help plz
function displayings(linking) {
var display = ".displays";
var dis = "." + linking;
$(display).has(dis).show();
$(display).not(dis).hide();
}
function showOptDivs(thelink) {
// this function takes the name of the link clicked, and confirms it class to view on the page, while hiding the ones not
var linkcheck = $("#all-options-links a").has(thelink);
$(".displays").hide();
//$(thelink).css("background-color":"whitesmoke","color":"black");
if (linkcheck) {
var textline = ".trigger";
var id = $(thelink).attr("id");
var combine = textline + "-" + id; // this creates a class name of the selected content menu item to match
$(combine).show(); // show the created class
var shown = $(combine).show(); // assign the event of showing the selected item to the variable
// check if the event is successful then hide all trigger which dont have same class though sharing .trigger class
if (shown) {
$(textline).not(combine).hide(); // hide all class which are not selected
$(combine).addClass(textline); // add the stryle being held with .trigger from css file
var firstdiv = combine + " div"; // this is to get the child div of the shown div class
var getdivclassname = $(firstdiv).first().attr("class"); // getting the name of the first div or child of the chosen or shoen div class
var firstdivname = "." + getdivclassname + " div"; // get the di which is descendant of the chosen class
var divlinksclass = $(firstdivname).attr("class"); // getting the class of all the links in the selected class of the first div
var linkforid = "." + divlinksclass; // turning the class name into a class element by adding .
var linksholderdiv = "." + linkforid + " a";
// this i to get rrhe links of each menu item display once displayed, to prompt automtic hiding and showing of the elements
$(linksholderdiv).click(function() {
var clickedlinkid = $(this).attr("id"); // get the link id of the clicked item thenhide and show other elements
var clickedlinkclass = $(this).attr("class");
var turnedintoclass = "." + clickedlinkid; // the class for the displaying
if (displayings(clickedlinkid)) {
alert("executed");
}
//displayings(clickedlinkid);
else {
alert("not executed");
}
});
}
} // end of if statement
} // end of the showOptDivs