somewebmedia / hc-offcanvas-nav

JavaScript library for creating toggled off-canvas multi-level navigations, allowing endless nesting of submenu elements, supporting swipe gestures, keyboard interactions and ARIA attributes.
https://somewebmedia.github.io/hc-offcanvas-nav/
MIT License
336 stars 82 forks source link

Render out HTML Object in Nav Title #67

Closed BrandanKing closed 2 years ago

BrandanKing commented 3 years ago

Hi,

You added the ability to render out a HTML element as NavTitle #47 Is it possible that you could update your doc / show me how to actually create the JS element required to make this render properly please.

Thanks

somewebmedia commented 3 years ago

Vanilla JS:

var title = document.createElement('div');
title.appendChild(document.createTextNode('Hi there!'));

var Nav = new hcOffcanvasNav('#main-nav', {
  navTitle: title
});

jQuery:

var Nav = new hcOffcanvasNav('#main-nav', {
  navTitle: $('<div>Hi there!</div>')
});