1,297
9
Essay, 1 pages (100 words)

Extract id value from css class to javascript variable

I have a ul menu from which I want to retireve certain information


  • Maths

I have a function in javascript:

function getSessionDatas(){
var sessions = [];
$(‘. rightDiv’). each(function( index ) {
var session = $. trim($(this). text(). slice(0,-1)). split(“×”);
var sessionData = [];
for (var i = 0; i < session. length; i++) {
var s = {subjectOrder: i, subjectID: subs[session[i]]};
sessionData. push(s);
}
var ses = {sessionNo: index, sessionData: sessionData};
sessions. push(ses);
});
}

Here:

var s = {subjectOrder: i, subjectID:};

I want to assign the subject id according to the class of the

  • item, in this case in the class there is an id10. How can i assign the subjectID to 10 in this case?

  • Thank's for Your Vote!
    Extract id value from css class to javascript variable. Page 1
    Extract id value from css class to javascript variable. Page 2

    This work, titled "Extract id value from css class to javascript variable" was written and willingly shared by a fellow student. This sample can be utilized as a research and reference resource to aid in the writing of your own work. Any use of the work that does not include an appropriate citation is banned.

    If you are the owner of this work and don’t want it to be published on AssignBuster, request its removal.

    Request Removal
    Cite this Essay

    References

    AssignBuster. (2021) 'Extract id value from css class to javascript variable'. 26 December.

    Reference

    AssignBuster. (2021, December 26). Extract id value from css class to javascript variable. Retrieved from https://assignbuster.com/extract-id-value-from-css-class-to-javascript-variable/

    References

    AssignBuster. 2021. "Extract id value from css class to javascript variable." December 26, 2021. https://assignbuster.com/extract-id-value-from-css-class-to-javascript-variable/.

    1. AssignBuster. "Extract id value from css class to javascript variable." December 26, 2021. https://assignbuster.com/extract-id-value-from-css-class-to-javascript-variable/.


    Bibliography


    AssignBuster. "Extract id value from css class to javascript variable." December 26, 2021. https://assignbuster.com/extract-id-value-from-css-class-to-javascript-variable/.

    Work Cited

    "Extract id value from css class to javascript variable." AssignBuster, 26 Dec. 2021, assignbuster.com/extract-id-value-from-css-class-to-javascript-variable/.

    Get in Touch

    Please, let us know if you have any ideas on improving Extract id value from css class to javascript variable, or our service. We will be happy to hear what you think: [email protected]