The operation of any multiplexer (MUX for short) is conceptually the same, be it analog or digital.
In essence you have a set of numbered data inputs (usually a power of 2, say \$N=2^n\$ inputs named, say, \$X_0, X_1,\$ ... etc.), a set of digital selection inputs (in number of \$n\$) and an output. A mux works by sending one (and only one) data input signal to the output. The data input to be "routed" to the output is the one selected using the selection inputs, i.e. the one whose number, expressed in binary, is put on the selection inputs.
In other words, a mux acts like a digitally-selectable single-pole/N-throw switch.
The difference between analog and digital muxes, seen from the outer world, is that the data inputs and the output are digital (two-level) for digital muxes, whereas in analog muxes the data signals can be analog.
The common implementation, in the two cases, is quite different. Analog muxes are made using FET switches (most commonly MOSFET transmission gates) and they act more like actual switch arrays, without amplification of the switched signals.
Take as an example the common 74HC4051 analog mux:
Here S0, S1 and S2 are the selection inputs, /E is the enable input (all four pins are digital), whereas Y0..Y7 are the analog data inputs and Z is the analog output. Note that in this case you can also reverse the role of the analog inputs and output and get a demultiplexer (a.k.a. DEMUX).
In particular, see how a single switch is implemented:
Digital muxes, on the other hand, use a bunch of digital logic gates to steer signals from (digital) inputs to the (digital) output. Digital muxes amplify the signal, since the internal gates are, after all, buffer amplifier.
You can refer to the Wikipedia article about the mulitplexer to understand how a digital multiplexer works internally. Actual implementations don't differ too much.
Take as an example the common 74HC151 digital mux and its internal logic diagram:
In this case they use I0,I1,...,I7 for the data inputs and Y for the output (they also provide a negated output for free).